Trouble building Ruby in Ubuntu 18.04

I've been having trouble building Ruby 3.0 under Ubuntu 18.04.

I started by cloning the source repository, and building the head of the main branch.

Six extension libraries failed to build: dbm, gdbm, openssl, fiddle, readline, and zlib.

Openssl was my main concern, since I can't run "gem install" without it.

I was following the instructions in the main ruby repository's ReadMe, which were pretty good up to a point (the very point that I was now at). What they have to say at this point is _really_ not helpful:

    Some extension libraries may not get compiled because of lack of
    necessary external libraries and/or headers, then you will need to
    run 'make distclean-ext' to remove old configuration after
    installing them in such case.

Not helpful point #1: There are no links or advice to help me find the "lacking" external libraries or headers. I'm left to do an unanticipated research project without any guidance.

Not helpful point #2: What is the use of 'make distclean-ext'? My understanding of Make conventions, and the listing I got from running it show that its purpose is to return _all_ of the extension subdirectories to their pristine, pre-make state. It certainly doesn't single out or do anything special to the extensions that did not build, and it undoes useful work in the extensions that did build. It doesn't appear that any of this would be helpful in getting the any of the broken builds fixed, yet it is recommended as part of the solution, without any guidance as to how it might help.

So I started on my six unanticipated research projects. There are "mkmf.log" files in the extension directories to give me some clues. In the openssl case, there were two unresolved references, "t_open() in -lnsl" and "socket() in -lsocket". So far so good. There is also a suggestion to add the control flag "--with-openssl-dir-<dir>" to something unspecified. The "make" command line? the "./config" command line? one of the generated configuration files? I'm willing to do only so much trial and error to figure out something I could have been told.

I also verified that openssl (version 1.1.1f, 31 Mar 2020) is installed on my machine in /usr/lib/ssl. That's a fairly obvious place to look. Why is it necessary for me to tell the Ruby build something that should be obvious?

I eventually took note of the little icons at the top of the README.md file. There is one for each operating system that give it a "passing" or "failing" grade. The head of the main branch showed a "failing" grade for Ubuntu. So, I thought, let me back up to a more stable place with a passing grade. So I looked at the "ruby_3_0" branch. It indeed has a passing grade for Ubuntu. So I switched to that branch and started over.

S A M E R E S U L T

I have so far wasted two days on something that should have taken hours to resolve at most. Needless to say, I'm upset. Can anyone tell me what I missed that would have saved me all this aggravation?

                             \-\- Jens Dill \(hopeful Ruby developer\)

P.S. Some of what I say here is worth reporting as an issue with the Ruby installation instructions. I don't see an obvious place to report such issues officially. I don't really want to clutter up the stream of real bug reports at this time. Is there a place I should send this?

On ubuntu 20.04 i had exactly that problem:

check if you have -dev versions of packages installed as well as the package.They are required for building applications.

eg

apt list --installed | grep -- '-dev'

...

libedit-dev/focal,now 3.1-20191231-1 amd64 [installed]
libgdbm-compat-dev/focal,now 1.18.1-5 amd64 [installed]
libgdbm-dev/focal,now 1.18.1-5 amd64 [installed]
libncurses-dev/focal,now 6.2-0ubuntu2 amd64 [installed]
libpam0g-dev/focal-updates,now 1.3.1-5ubuntu4.1 amd64 [installed]
libreadline-dev/focal,now 8.0-4 amd64 [installed]
libssl-dev/focal-updates,focal-security,now 1.1.1f-1ubuntu2.1 amd64 [installed]
...

···

On 2021-01-08 2:16 p.m., Jens Dill wrote:

dbm, gdbm, openssl, fiddle, readline, and zlib.

The build issue has been resolved, thanks to a private message from Robert Burrowes, who listed the packages he had to install to get his build to work:

apt-get install -y build-essential
apt-get install -y zlib1g-dev
apt-get install -y libreadline-dev
apt-get install -y libyaml-dev
apt-get install -y libgdbm-dev
apt-get install -y liblzma-dev
apt-get install -y libxml2-dev
apt-get install -y bison

I also had to add "apt-get install -y libffi-dev" before I got a clean build.

That leaves only the documentation issue. The paragraph I quoted below from the Ruby README is really not helpful, as I noted in my original message. Much more helpful would be a paragraph that says the same thing about "lack of necessary external libraries" and then points to a place (in the Wiki?) that lists the necessary external libraries and tells you how to get them for each platform. How do I raise this issue officially with the Ruby Development team?

                           \-\- Jens
···

On 2021-01-08 2:16 PM, Jens Dill wrote:

I've been having trouble building Ruby 3.0 under Ubuntu 18.04.

...

I was following the instructions in the main ruby repository's ReadMe, which were pretty good up to a point (the very point that I was now at). What they have to say at this point is _really_ not helpful:

    Some extension libraries may not get compiled because of lack of
    necessary external libraries and/or headers, then you will need to
    run 'make distclean-ext' to remove old configuration after
    installing them in such case.

Not helpful point #1: There are no links or advice to help me find the "lacking" external libraries or headers. I'm left to do an unanticipated research project without any guidance.

Not helpful point #2: What is the use of 'make distclean-ext'? My understanding of Make conventions, and the listing I got from running it show that its purpose is to return _all_ of the extension subdirectories to their pristine, pre-make state. It certainly doesn't single out or do anything special to the extensions that did not build, and it undoes useful work in the extensions that did build. It doesn't appear that any of this would be helpful in getting the any of the broken builds fixed, yet it is recommended as part of the solution, without any guidance as to how it might help.

...

P.S. Some of what I say here is worth reporting as an issue with the Ruby installation instructions. I don't see an obvious place to report such issues officially. I don't really want to clutter up the stream of real bug reports at this time. Is there a place I should send this.