如何使用mac os将ruby版本更改为2.6.5 ?



我需要将我的ruby版本更改为2.6.5以获得一个运行于现有应用程序的开发环境,但是当我试图安装它时,我得到一个奇怪的错误。

Macbook pro

M2

13.1文图拉

ruby -v: 3.0.0

node -v: 16.12.0

我已经安装了RVM,当我进入终端切换ruby版本时,会发生以下情况:

rvm use 2.6.5
Required ruby-2.6.5 is not installed.
To install do: 'rvm install "ruby-2.6.5"'

下一步我尝试安装2.6.5

rvm install 2.6.5
ruby-2.6.5 - #removing src/ruby-2.6.5 - please wait
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/13.1/arm64/ruby-2.6.5.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Updating certificates bundle '/opt/homebrew/etc/openssl@1.1/cert.pem'
Requirements installation successful.
Installing Ruby from source to: /Users/placeholder/.rvm/rubies/ruby-2.6.5, this may take a while depending on your cpu(s)...
ruby-2.6.5 - #downloading ruby-2.6.5, this may take a while depending on your connection...
ruby-2.6.5 - #extracting ruby-2.6.5 to /Users/placeholder/.rvm/src/ruby-2.6.5 - please wait
ruby-2.6.5 - #configuring - please wait
ruby-2.6.5 - #post-configuration - please wait
ruby-2.6.5 - #compiling - please wait
Error running '__rvm_make -j8',
please read /Users/placeholder/.rvm/log/1671569360_ruby-2.6.5/make.log
There has been an error while running make. Halting the installation.

make.log文件只是一个试图进行更改的ruby代码片段。
有什么建议吗?

根据anothermh的建议,卸载rbenv和brew版本的Ruby

卸载

brew uninstall ruby用于删除brew版本

在这篇文章中使用已接受的答案删除rbenv

安装RVM

按照指令安装RVM || as per this

rvm install (ruby version)

rvm --default use (ruby version)

可以使用rvm list查看可用的ruby版本。

使用rvm:

安装ruby版本

rvm install 2.6.5

设置并使用默认值2.6.5:

rvm use 2.6.5 --default

我最终卸载了RVM并切换到rbenv,经过大量的故障排除后,运行这个命令获得了所需的Ruby 2.6.5版本来安装。因此,对于任何使用相同的带有M2芯片的Macbook pro,需要在旧版本的ruby上工作的人来说,这是我使用的命令。

RUBY_CFLAGS="-w" rbenv install 2.6.5 

另外,如果有人遇到麻烦,这对你不起作用,我通过这个github讨论找到了这个答案,还有很多其他的解决方案,适用于其他各种情况。

从github安装Macbook pro M1/M2芯片