如何使用RVM重新编译Ruby以支持OpenSSL?

3

通过 RVM 安装 Ruby 2.3.8 后,运行 bundle 命令时出现以下错误:

You must recompile Ruby with OpenSSL support or change the sources in your Gemfile

我该如何重新编译带有 OpenSSL 支持的 Ruby?


你是否尝试按照错误信息建议的方式重新编译带有OpenSSL支持的Ruby? - Stefan
是的,我尝试了多种解决方案,甚至花了一整天的时间来解决这个问题。但是在花费了这么多时间之后,我发现只有以下答案适用于我的情况。 - Shivam
抱歉,我没有看到你自己回答了这个问题。 - Stefan
2个回答

4

我的解决方案:

只需执行以下步骤:

1:安装 Homebrew:https://brew.sh/

2:运行以下命令:

rvm install 2.3 --with-openssl-lib=/usr/local/opt/openssl/lib --with-openssl-include=/usr/local/opt/openssl/include

(如果已经安装了 rvm,请使用 reinstall 命令代替 install 命令。)


这个也可能有效:https://dev59.com/qWUp5IYBdhLWcg3wHUri#54236670 - Stefan

1

针对MacOS Mojave上的rvm

在我的情况下,安装程序失败是因为它在新版本的openssl中使用了过时的部件。这对我有用:

  1. Go to the "homebrew-core" folder and get back the old openssl gem(1.0.2t)

    cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
    git show 8b9d6d688f483a0f33fcfc93d433de501b9c3513:Formula/openssl.rb >> Formula/openssl\@1.0.2t.rb
    
  2. Enter the file and rename the class "Openssl" to "OpensslAT102t"

    brew edit Formula/openssl\@1.0.2t.rb
    
  3. Install it with brew

    brew install openssl@1.0.2t
    
  4. Once installed, force rvm to use the installed version of ssl

    # Install 2.3.8
    rvm install 2.3.8 --disable-binary --with-openssl-dir=`brew --prefix openssl@1.0.2t`
    # Or reinstall
    rvm reinstall 2.3.8 --disable-binary --with-openssl-dir=`brew --prefix openssl@1.0.2t`
    

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接