如何为 Ruby makefile 提供配置选项?世界超级联赛,Ubuntu 20.04

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

[TL;DR:解决方案是安装 libssl-dev。请参阅下面我对自己的回答,它也解决了相关问题。]

[原问题:]我正在尝试在 WSL/Ubuntu 20.04 环境中更新一些 Ruby gem。具体来说,我正在尝试更新 openssl gem。我想我理解错误消息并且几乎 理解如何解决它。我需要将目录作为配置选项提供给 openssl。我只是不知道该怎么做。这是错误消息的相关部分:

*** 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)

好的,所以我明白我应该使用 --with-openssl-dir=<dir> 来提供 OpenSSL 的路径(在 /usr/lib/ssl 中)。

但是 我该怎么做? 据我了解,这是一个编译标志,应该放在生成文件中或在编译时传递。但我不明白我应该编辑什么文件来传递这个标志。我阅读了 extconf.rb 文件,就我的理解而言,我看不出这个标志应该放在哪里。我也没有看到要编辑的 makefile(如果它是在编译时动态生成的,那无论如何都不是正确的方法)。

我意识到这对某些人来说可能是显而易见的,但对我来说却并非如此,我花了相当多的时间来弄明白。

好吧,我不知道如何做我问的(在 makefile 中传递一个标志),但我已经解决了我的问题,它比 openssl 包更通用,甚至尽管那是错误信息最清楚的那个。基本问题是 Ruby 想要为 openssl 安装 -dev 软件包和其他几个无法更新的 gem。以下是无法更新的每个 gem,以及我如何解决错误:

  • openssl
    • 错误: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)
    • 解决方案:
sudo apt install libssl-dev
sudo gem update openssl
  • zlib
    • 错误:
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 ***
  • 解决方案:
sudo apt install zlib1g-dev
sudo gem update zlib
  • fiddle
    • 错误:extconf.rb:87:in '<main>': missing libffi. Please install libffi.
    • 解决方案:
sudo apt install libffi-dev
sudo gem update fiddle
  • net-popnet-smtp
    • 这两个都失败了,并显示相同的错误消息,这实际上提供了很多信息: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
    • 解决方案:
sudo gem install io-wait -v 0.1.0 
sudo gem update net-pop
sudo gem update net-smtp
  • readline-ext
    • 同样,错误消息提供了相当多的信息:Neither readline nor libedit was found (RuntimeError)
    • 解决方案:
sudo apt install libreadline-dev 
sudo apt install libedit-dev
sudo gem update readline-ext

注意:我知道使用 sudo 在系统范围内更新 gem 可能不是最佳做法。但这是我所做的。我也明白其中一些错误信息可能很明显;这就是为什么我没有在我的第一个 post 中提到它们。但它正在解决 zlibfiddle 问题,使我了解 openssl 问题的解决方案,所以我想我会 post 所有这些信息,因为所有错误都出现在同一安装工作中。