安装 Ruby 2.2.6 时 macOS Sierra 的 RVM 问题
Posted
技术标签:
【中文标题】安装 Ruby 2.2.6 时 macOS Sierra 的 RVM 问题【英文标题】:RVM issue with macOS Sierra while installing Ruby 2.2.6 【发布时间】:2017-07-04 06:09:02 【问题描述】:我正在运行 OSX (10.12.3) 并且安装了 Ruby (2.2.2),它运行良好。我正在尝试使用 RVM 升级到 2.2.6。安装似乎很顺利。
- rvm install 2.2.6
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.12/x86_64/ruby-2.2.6.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
Installing Ruby from source to: /location/.rvm/rubies/ruby-2.2.6, this may take a while depending on your cpu(s)...
ruby-2.2.6 - #downloading ruby-2.2.6, this may take a while depending on your connection...
ruby-2.2.6 - #extracting ruby-2.2.6 to /location/.rvm/src/ruby-2.2.6....
ruby-2.2.6 - #configuring..........................................................
ruby-2.2.6 - #post-configuration.
ruby-2.2.6 - #compiling...........................................................
ruby-2.2.6 - #installing..........
ruby-2.2.6 - #making binaries executable..
ruby-2.2.6 - #downloading rubygems-2.6.10
ruby-2.2.6 - #extracting rubygems-2.6.10.....
ruby-2.2.6 - #removing old rubygems.........
$LANG was empty, setting up LANG=en_US, if it fails again try setting LANG to something sane and try again.
ruby-2.2.6 - #installing rubygems-2.6.10.....................
ruby-2.2.6 - #gemset created /location/.rvm/gems/ruby-2.2.6@global
ruby-2.2.6 - #importing gemset /location/.rvm/gemsets/global.gems................................................
ruby-2.2.6 - #generating global wrappers........
ruby-2.2.6 - #gemset created /location/.rvm/gems/ruby-2.2.6
ruby-2.2.6 - #importing gemsetfile /location/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.2.6 - #generating default wrappers........
ruby-2.2.6 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.2.6 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
但是当我尝试执行命令时,我会得到一些错误。
- bundle
-bash: bundle: command not found
- gem install bundler
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
因此,虽然安装似乎很顺利,但在尝试安装任何 gem 时都不需要 openssl。这里可能是什么问题,我该如何解决?
【问题讨论】:
【参考方案1】:我尝试清除整个 RVM 并重新安装,但没有帮助。使用来自 here 的 phq 的答案,我设法让它工作了。
rvm remove 2.2.6
rvm pkg install openssl
rvm install 2.2.6 --with-openssl-dir=$HOME/.rvm/usr
gem install bundler
bundle
它可能不是最好的解决方案,因为它手动加载 openssl,但它似乎是目前唯一适合我的解决方案。
【讨论】:
【参考方案2】:如果您还没有安装Homebrew,您应该继续尝试一下。正如他们所说,“Homebrew 安装了你需要的东西,而 Apple 没有”,在你的例子中是 openssl。
-
安装 Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装openssl:brew install openssl
再次尝试安装捆绑程序:gem install bundler
为了避免以后出现问题,我建议你看看RVM Autolibs。它会使用 Homebrew 或其他管理器自动安装您需要的任何依赖项。如果您不想阅读文档,只需运行:rvm autolibs enable && rvm autolibs packages && rvm autolibs homebrew
就可以了。
【讨论】:
我正在使用 Homebrew 并且当时安装了 OpenSSL。另外,我启用了 autolibs(默认情况下),似乎有一些问题导致它没有正确配置 autossl(从我的回答中可以看出)。以上是关于安装 Ruby 2.2.6 时 macOS Sierra 的 RVM 问题的主要内容,如果未能解决你的问题,请参考以下文章
在 Apple Silicon M1 上使用 Ruby 3.0.2 在 MacOS Monterey 上安装 sqlite3 时出错
MacOs (M1 Arm64) 无法加载 Nokogiri - 使用系统默认 Ruby
通过 Homebrew 在 MacOS 上使用 asdf 安装 ruby