【发布时间】:2020-08-06 02:35:40
【问题描述】:
我需要使用 Ruby 2.2.2,但我的 macOS 附带 2.6.3。
我以 root 而非 root 身份尝试过的命令:
-
sudo brew install ruby@2.2.2和brew install ruby@2.2.2导致错误 -
sudo gem update --system 2.2.2和gem update --system 2.2.2导致程序自行中止
rvm 没有安装。
如何安装 Ruby 2.2.2?
编辑:
遵循以下建议
install RVM with \curl -sSL https://get.rvm.io | bash -s stable
Restart your shell
Install Ruby with rvm install 2.2.2
Verify you are using the correct version of Ruby with ruby -v
然后我得到了这个错误:
CL-CJAKOB-XMD6R:~ cjakob$ rvm install 2.2.2
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.2.2.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
Updating system......
Installing required packages: automake, libtool, coreutils, libyaml, libksba, zlib, openssl..............
==> Upgrading 2 outdated packages:
pkg-config 0.29.2 -> 0.29.2_3
readline 8.0.1 -> 8.0.4
==> Upgrading readline 8.0.1 -> 8.0.4
==> Downloading https://homebrew.bintray.com/bottles/readline-8.0.4.catalina.bot
==> Downloading from https://akamai.bintray.com/6a/6ae1c8e7c783f32bd22c6085caa4d
######################################################################## 100.0%
==> Pouring readline-8.0.4.catalina.bottle.tar.gz
==> Caveats
readline is keg-only, which means it was not symlinked into /usr/local,
because macOS provides BSD libedit.
For compilers to find readline you may need to set:
export LDFLAGS="-L/usr/local/opt/readline/lib"
export CPPFLAGS="-I/usr/local/opt/readline/include"
For pkg-config to find readline you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"
==> Summary
???? /usr/local/Cellar/readline/8.0.4: 48 files, 1.5MB
Removing: /usr/local/Cellar/readline/8.0.1... (48 files, 1.5MB)
==> Upgrading pkg-config 0.29.2 -> 0.29.2_3
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.2_3.catalin
==> Downloading from https://akamai.bintray.com/80/80f141e695f73bd058fd82e9f539d
######################################################################## 100.0%
==> Pouring pkg-config-0.29.2_3.catalina.bottle.tar.gz
???? /usr/local/Cellar/pkg-config/0.29.2_3: 11 files, 623.7KB
Removing: /usr/local/Cellar/pkg-config/0.29.2... (11 files, 623KB)
==> Checking for dependents of upgraded formulae...
==> Upgrading 2 dependents:
ruby-build 20200115 -> 20200401, ruby-build 20200115 -> 20200401
==> Upgrading ruby-build 20200115 -> 20200401
==> Downloading https://github.com/rbenv/ruby-build/archive/v20200401.tar.gz
==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v202004
######################################################################## 100.0%
==> ./install.sh
==> Caveats
ruby-build installs a non-Homebrew OpenSSL for each Ruby version installed and these are never upgraded.
To link Rubies to Homebrew's OpenSSL 1.1 (which is upgraded) add the following
to your ~/.bash_profile:
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
Note: this may interfere with building old versions of Ruby (e.g <2.4) that use
OpenSSL <1.1.
==> Summary
???? /usr/local/Cellar/ruby-build/20200401: 495 files, 245.2KB, built in 4 seconds
Removing: /usr/local/Cellar/ruby-build/20200115... (470 files, 234.4KB)
==> Checking for dependents of upgraded formulae...
Error: No such file or directory - /usr/local/Cellar/ruby-build/20200115
Requirements installation failed with status: 1.
CL-CJAKOB-XMD6R:~ cjakob$
我将如何从这里前进?
【问题讨论】:
-
为什么你需要使用 2.2.2(回答很重要,否则你可能会处理 XY 问题——如果你不知道什么是 xy 问题,请用谷歌搜索)。你的系统上可以有多个版本的 ruby:你需要一个 ruby 版本管理器来帮助你。你可以得到 RVM 或者你可以得到 rbenv。我会推荐后者,因为我不喜欢处理 RVM 中需要的 gemset。但 rvm 对您来说仍然是一个可行的选择。所以你可以使用你需要的任何 ruby 版本。现在回答您的问题:您可以尝试安装 RVM。
-
RVM 中需要的 gemsets 我已经专业和个人使用 RVM 超过 7 年,并且只处理过一次 gemsets。
-
按照说明安装了 rvm,但它导致了另一个错误,我已将其添加到我的问题中
-
重复您的
rvm install 2.2.2命令,看看它现在是否成功完成。如果没有,请运行brew doctor和brew upgrade,然后重试。
标签: ruby macos version homebrew