【问题标题】:troubles with RVM and OpenSSLRVM 和 OpenSSL 的问题
【发布时间】:2013-03-08 20:41:57
【问题描述】:

尝试为同事设置新的 macbook。进展不顺利。

首先我安装 OpenSSL:

Heathers-MacBook-Pro:~ heather$ rvm pkg install openssl
Fetching openssl-1.0.1c.tar.gz to /Users/heather/.rvm/archives
######################################################################## 100.0%
Extracting openssl to /Users/heather/.rvm/src/openssl-1.0.1c
Configuring openssl in /Users/heather/.rvm/src/openssl-1.0.1c.
Compiling openssl in /Users/heather/.rvm/src/openssl-1.0.1c.
Installing openssl to /Users/heather/.rvm/usr

Please note that it's required to reinstall all rubies:

    rvm reinstall all --force

Updating openssl certificates

然后我尝试用 openssl 安装 ruby​​...

Heathers-MacBook-Pro:website heather$ rvm install 1.9.3 --with-openssl-dir=$HOME/.rvm/usr
Fetching yaml-0.1.4.tar.gz to /Users/heather/.rvm/archives
Extracting yaml to /Users/heather/.rvm/src/yaml-0.1.4
Configuring yaml in /Users/heather/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/heather/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/heather/.rvm/usr
Installing Ruby from source to: /Users/heather/.rvm/rubies/ruby-1.9.3-p392, this may take a while depending on your cpu(s)...
ruby-1.9.3-p392 - #downloading ruby-1.9.3-p392, this may take a while depending on your connection...
ruby-1.9.3-p392 - #extracting ruby-1.9.3-p392 to /Users/heather/.rvm/src/ruby-1.9.3-p392
ruby-1.9.3-p392 - #extracted to /Users/heather/.rvm/src/ruby-1.9.3-p392
ruby-1.9.3-p392 - #configuring
ruby-1.9.3-p392 - #compiling
ruby-1.9.3-p392 - #installing 
Removing old Rubygems files...
Installing rubygems-1.8.25 for ruby-1.9.3-p392 ...
Installation of rubygems completed successfully.
Saving wrappers to '/Users/heather/.rvm/bin'.
ruby-1.9.3-p392 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.9.3-p392 - #importing default gemsets, this may take time ...
Install of ruby-1.9.3-p392 - #complete 

Heathers-MacBook-Pro:website heather$ bundle update
Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your Gemfile from 'https' to 'http'. Instructions for
compiling with OpenSSL using RVM are available at rvm.io/packages/openssl.

顺便说一句,gem 文件显示“source https://rubygems.org

想法?

【问题讨论】:

    标签: ruby openssl rvm


    【解决方案1】:

    OP 实际上拯救了我的一天! 就我而言:

    $ rvm pkg install openssl
    $ rvm remove 2.4
    $ rvm install 2.4 --with-openssl-dir=$HOME/.rvm/usr
    $ gem install bundler
    

    【讨论】:

    • 原来在 Debian 上你确实不需要需要libssl-dev;你需要libssl1.0-dev。运行您的命令序列突出显示了差异并解决了我的问题,现在 2.1.10 已成功安装。谢谢。
    • 谢谢!非常适合在 ubuntu 18.04 上运行 ruby​​ 1.8.7
    • 就我而言,这是唯一有效的解决方案。正在尝试安装 ruby​​ 2.3.6,它在升级自制程序包 brew upgrade pyenv 后损坏,以及其他一些留下 brew list 的 brew 更新显示 openssl & openssl@1.1 这就是我的问题开始的时候。
    【解决方案2】:

    试试这个:

    rvm get head
    rvm pkg remove
    rvm requirements run  # if brew gives you warnings about formulas to install, run "brew install" for each before moving on.
    
    rvm reinstall [the version you need (i.e: 2.0.0)]
    

    【讨论】:

    • 一个澄清的评论 - 运行“rvm 要求运行”会给你一堆缺失的自制公式。为每个运行“brew install”。
    • 我在rvm get head 上失败了Error running 'command gem install /Users/daniellizik/.rvm/gem-cache/rvm-1.11.3.9.gem --local --no-document'...ERROR: Loading command: install (LoadError) cannot load such file -- openssl
    【解决方案3】:

    ArchLinux wiki 上有很好的描述:

    早于 2.4 的 Ruby 版本需要 OpenSSL 1.0,但 RVM 将尝试使用 OpenSSL 1.1 构建它们。

    所以你可以做(​​最简单的):

    $ rvm pkg install openssl
    $ rvm reinstall 2.3.5 --with-openssl-dir=$HOME/.rvm/usr
    

    您可以在ArchLinux wiki查看更多解决方案。

    【讨论】:

    • 您的命令中缺少一个破折号:--with-openssl-dir=...
    • 它对我有用。我想了解它是如何工作的。有什么收获?
    • @jaspreet21anand我现在使用 rbenv:github.com/rbenv/rbenv/wiki/Why-rbenv%3F
    • 如你所说,rvm 使用了错误的版本,但你只指定了 openssl 目录。你怎么会有 1.0 而不是 1.1
    【解决方案4】:

    使用 Homebrew 在 macOS Mojave (10.14.2) 上安装 Ruby 2.2。

    Install Homebrew

    brew install openssl
    rvm install 2.2 --with-openssl-dir=/usr/local/opt/openssl
    

    不要使用rvm pkg,它是deprecated,使用rvm autolibs enabled

    【讨论】:

      【解决方案5】:

      以下是我在装有 Catalina 的 Mac 上安装 rvm 和 ruby​​ 2.3 的方法。安装的 rvm 版本是 1.29.9。必须安装 OpenSSL 1.0.2(降级)。请注意 gpg 命令中的“ipv4”。

      gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
      \curl -sSL https://get.rvm.io | bash -s stable
      

      https://www.openssl.org/source/下载openssl 1.0.2

      tar -xzf openssl-1.0.2t.tar.gz
      cd openssl-1.0.2t
      ./Configure darwin64-x86_64-cc --prefix=/usr/local/opt/openssl@1.0
      make
      make test
      sudo make install
      
      rvm install 2.3.3 --with-openssl-dir=/usr/local/opt/openssl@1.0
      ruby -v
      ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'              
      >> OpenSSL 1.0.2t  10 Sep 2019
      

      【讨论】:

      • 我有不同的项目在工作。根据上述评论,2.3.3 版本的项目工作正常。您能否添加哪个 openssl 版本适用于 Ruby 2.5.3 和 Catalina 中的 Rails 5.2.1?
      • 这也适用于 ruby​​
      • 谢谢你解释得这么漂亮。为 mac os Catalina 工作。
      • 如果出于任何原因您需要多个红宝石和宝石组,这是迄今为止最简洁的解决方法(使用像
      【解决方案6】:

      在 MacOS 10.12.2 上,通过 brew 安装 openssl 将不起作用。要修复它,请运行:

      export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig:/usr/local/lib/pkgconfig
      

      然后通过 rvm 安装 Ruby。

      编辑: 有关问题背后原因的更多信息here

      【讨论】:

      • 这对于旧版本的 Ruby 更为重要,因为旧版本可能无法在新版本的 openssl 上正常工作,例如1.1。此设置对于使 rvm 的 --with-openssl-dir 选项起作用至关重要。
      【解决方案7】:

      对于那些在 Mac Mojave 上通过 RVM 使用 openssl 1.1 和 Ruby 2.3 的用户,您可以尝试以下命令。问题是 Ruby 2.3 与 openssl 1.1 不兼容

      rvm pkg install openssl
      PKG_CONFIG_PATH=$HOME/.rvm/usr/lib/pkgconfig rvm reinstall 2.3.3 --with-openssl-dir=$HOME/.rvm/usr
      

      【讨论】:

        【解决方案8】:

        这对我有用:

        brew install rbenv/tap/openssl@1.0
        rvm reinstall 1.9.3-p551 --with-openssl-dir='/usr/local/opt/openssl@1.0'
        gem update --system
        

        干杯!

        【讨论】:

        • 这在 Catalina、rvm、ruby 2.1.9 上对我有用。现在我古老的测试工具又可以工作了!
        【解决方案9】:

        对于 MacOS High Sierra 10.13.6 上的旧版 ruby​​ 2.2.10,唯一对我有用的是:

        1. 切换到较旧的 OpenSSL 版本
        brew switch openssl 1.0.2s
        
        1. 比使用--with-openssl-dir重新安装ruby
        rvm reinstall 2.2.10 --with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s
        

        【讨论】:

        • 谢谢!这有助于在 High Sierra 10.13.6 上安装旧的 Ruby 2.3.0。否则新的 openssl 1.1.x 不兼容
        • 我遇到的问题是,如果我没有通过 brew 安装 openssl 1.0.x(来自一个古老的遗留物),小桶不再存在,所以你不能实际安装openssl 1.0.x 不再通过自制软件直接。您必须首先弄清楚如何通过自制软件实际 get openssl1.0.x 安装。请参阅 Chris Hobbs 或 hernan 的答案。
        • 非常感谢,这帮助我在 macOS Catalina 10.15.4 上运行了一个旧的 Ruby 2.2.7 项目
        【解决方案10】:

        所以这对我有用:

        rvm pkg install openssl
        rvm reinstall all --force
        

        我也有 rvm autolibs rvm_pkg 以获得 readline 支持。

        【讨论】:

          【解决方案11】:

          openssl 版本:1.0.2k

          这对我有用:

          brew reinstall openssl
          

          【讨论】:

          • 这有助于 OSX Mojave 使用其标准 bash 脚本安装 RVM。
          【解决方案12】:

          适用于 MacOS 上的 rvm

          首先,检查你是否安装了openssl。您应该会看到如下内容:

          $ brew --prefix openssl
          /usr/local/opt/openssl@1.1
          

          如果未安装 openssl,请安装。

          $ brew install openssl
          $ brew unlink openssl
          $ brew link --force openssl
          

          如果您安装了多个 openssl,请考虑删除除一个以外的所有内容,以使您的生活更轻松。

          $ brew cleanup openssl
          $ brew list --versions openssl
          $ brew uninstall <unwanted-openssl-version-here>
          

          现在重新安装 ruby​​ 版本,指定所需的 openssl 路径。

          $ rvm reinstall <your-version-here> --with-openssl-dir=`brew --prefix openssl`
          

          最后,验证你的 ruby​​ 是用它链接到的相同 openssl 编译的。如果你两次看到相同的版本,你应该已经准备好了。

          $ ruby -ropenssl -e'puts OpenSSL::OPENSSL_VERSION, OpenSSL::OPENSSL_LIBRARY_VERSION'
          OpenSSL 1.1.1d  10 Sep 2019
          OpenSSL 1.1.1d  10 Sep 2019
          

          如果您稍后安装其他版本的 ruby​​,您将需要传递相同的 --with-openssl-dir 参数。或者,我相信您可以在 bash 配置文件中设置以下变量。

          export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(brew --prefix openssl)/lib/pkgconfig"
          export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix openssl)/lib"
          

          如果上述方法不起作用,请从您的 bash 配置文件中删除这些行,然后像上面一样使用 --with-openssl-dir 参数。

          参考:https://github.com/rvm/rvm/issues/4562 参考:https://bugs.ruby-lang.org/issues/12630

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2015-01-28
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多