出现ruby环境异常时候,不要慌,可能你的ruby版本过低或者不兼容所知,具体信息也可以根据提示前往/Users/linqipeng/.rvm/log/1695818501_ruby-3.0.0/remove.rubies.log查看,进行处理或者重装
Error running '__rvm_rm_rf /Users/linqipeng/.rvm/rubies/ruby-3.0.0',
please read /Users/linqipeng/.rvm/log/1695818501_ruby-3.0.0/remove.rubies.log
//直接重装,先移除
linqipeng@linqipeng ~ % rvm remove 2.6.10p210
ruby-2.6.10p210 - #already gone
Using /Users/linqipeng/.rvm/gems/ruby-3.0.0
linqipeng@linqipeng ~ % ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin23]
linqipeng@linqipeng ~ % rvm uninstall 2.6.10p210
ruby-2.6.10p210 - #already gone
linqipeng@linqipeng ~ % ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin23]
//查看当前ruby命令:which -a ruby,可以且只看到系统自带的ruby的位置/usr/bin/ruby
linqipeng@linqipeng ~ % which -a ruby
/usr/bin/ruby
👉安装自己新的ruby,系统自带的ruby不要删哈!!!
linqipeng@linqipeng ~ % brew install ruby
【👆从上面的安装过程的输出信息中,可以看到以下进一步相关设置引导说明】
//👉如果你需要先在路径中使用ruby
If you need to have ruby first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
//👉为了让编译器找到ruby,您可能需要设置
For compilers to find ruby you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/ruby/lib"
export CPPFLAGS="-I/opt/homebrew/opt/ruby/include"
//👉为了让pkg配置找到ruby,你可能需要设置
For pkg-config to find ruby you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/ruby/lib/pkgconfig"
👉先查看当前ruby所引用的路径
linqipeng@linqipeng ~ % which -a ruby
/usr/bin/ruby
👉再根据上面输出情形配置ruby引导,进行设置
linqipeng@linqipeng ~ % echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc
linqipeng@linqipeng ~ % source ~/.zshrc
linqipeng@linqipeng ~ % ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin23]
//👉命令:which -a ruby,查看电脑中安装的ruby:
linqipeng@linqipeng ~ % which -a ruby
/opt/homebrew/opt/ruby/bin/ruby文章来源:https://www.toymoban.com/news/detail-758619.html
/opt/homebrew/opt/ruby/bin/ruby
/opt/homebrew/opt/ruby/bin/ruby
/opt/homebrew/opt/ruby/bin/ruby
/usr/bin/ruby
//👉命令:which ruby,查看路径中使用的ruby:
linqipeng@linqipeng ~ % which ruby
/opt/homebrew/opt/ruby/bin/ruby
666,恭喜你,完成✅文章来源地址https://www.toymoban.com/news/detail-758619.html
到了这里,关于MacOS下,ruby安装与正确版本及路径设置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!