Home > OS >  How do I provide configuration options for a Ruby makefile? WSL, Ubuntu 20.04
How do I provide configuration options for a Ruby makefile? WSL, Ubuntu 20.04

Time:11-09

[TL;DR: The solution is installing libssl-dev. See my answer to myself, below, which also solves related problems).]

[Original question:] I am trying to update some Ruby gems in a WSL/Ubuntu 20.04 environment. Specifically, I'm trying to update the openssl gem. I think I understand the error message and almost understand how to solve it. I need to provide the directory to openssl as a configuration option. I just don't know how to do that. Here's the relevant part of the error message:

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
<snip>
--with-openssl-dir
<snip>
extconf.rb:98:in `<main>': OpenSSL library could not be found. 
You might want to use --with-openssl-dir=<dir> option to specify 
the prefix where OpenSSL is installed. (RuntimeError)

Okay, so I understand I should use --with-openssl-dir=<dir> to provide the path to OpenSSL (which is in /usr/lib/ssl).

But how do I do that? As I understand it, this is a compilation flag that should go in a makefile or be passed at compile time. But I don't understand what file I should edit to pass this flag. I read the extconf.rb file, and to the extent I understand it, I don't see where this flag should go. I also don't see a makefile to edit (and if it's generated dynamically at compile time, that wouldn't be the right approach anyway).

I realize this might be obvious to some, but it's not to me, and I spent a fair amount of time trying to figure it out.

CodePudding user response:

Well, I don't know how to do what I asked about (pass a flag in a makefile), but I have solved my problem, which is more general than just the openssl package, even though that was the one with the clearest error message. The basic issue is that Ruby wants the -dev packages installed for openssl and several other gems that could not be updated. Here are each of the gems that could not be updated, and how I solved the errors:

  • openssl
    • error: extconf.rb:98:in <main>: OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed. (RuntimeError)
    • solution:
sudo apt install libssl-dev
sudo gem update openssl
  • zlib
    • error:
checking for deflateReset() in -lz... no
checking for deflateReset() in -llibz... no
checking for deflateReset() in -lzlib1... no
checking for deflateReset() in -lzlib... no
checking for deflateReset() in -lzdll... no
checking for deflateReset() in -lzlibwapi... no
*** extconf.rb failed ***
  • solution:
sudo apt install zlib1g-dev
sudo gem update zlib
  • fiddle
    • error: extconf.rb:87:in '<main>': missing libffi. Please install libffi.
    • solution:
sudo apt install libffi-dev
sudo gem update fiddle
  • net-pop and net-smtp
    • These both failed with the same error message, which was actually pretty informative: The last version of io-wait (>= 0) to support your Ruby & RubyGems was 0.1.0. Try installing it with gem install io-wait -v 0.1.0 and then running the current command again
    • Solution:
sudo gem install io-wait -v 0.1.0 
sudo gem update net-pop
sudo gem update net-smtp
  • readline-ext
    • Again, the error message was fairly informative: Neither readline nor libedit was found (RuntimeError)
    • Solution:
sudo apt install libreadline-dev 
sudo apt install libedit-dev
sudo gem update readline-ext

Note: I understand that using sudo to update the gems system-wide may not be a best practice. But it's what I did. I also understand that some of these error messages may be obvious; that's why I didn't mention them in my first post. But it was solving the zlib and fiddle problems that clued me in to the solution to the openssl problem, so I figured I'd post all this information together, since all the errors arose in the same installation effort.

  • Related