MacOS升级ruby版本

MacOS自带ruby版本是2.x,可以通过"ruby -v"查看版本号

shell 复制代码
$ ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin22]

homebrew安装的ruby版本号可以通过"brew info ruby"命令参看

shell 复制代码
$ brew info ruby
==> ruby: stable 3.3.2 (bottled), HEAD [keg-only]
Powerful, clean, object-oriented scripting language
https://www.ruby-lang.org/

如果没有安装,可以"brew install ruby"进行安装

shell 复制代码
$ brew install ruby
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
Warning: ruby 3.3.2 is already installed and up-to-date.
...

或者通过"brew install ruby"进行升级

shell 复制代码
$ brew upgrade ruby
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
Warning: ruby 3.3.2 already installed

但是如果我们使用"ruby -v"查看版本,发现使用的还是MacOS自带ruby版本是2.x。这里就需要将homebrew中ruby环境加到系统PATH里,如下:

shell 复制代码
$ echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.profile

$ source ~/.profile

再次使用"ruby -v"查看一下版本

shell 复制代码
$ ruby -v
ruby 3.3.2 (2024-05-30 revision e5a195edf6) [x86_64-darwin22]
相关推荐
pe7er2 天前
macOS 应用无法打开(权限问题)解决方案
macos·mac
harmful_sheep4 天前
mac生效的终端查看
macos
iOS门童5 天前
macOS 应用"已损坏"无法打开?一文搞懂 Gatekeeper 与解决方案
macos
NPE~5 天前
[工具分享]Maccy —— 优雅的 macOS 剪贴板历史管理工具
macos·教程·工具·实用工具
差不多程序员5 天前
Mac安装OpenClaw-cn保姆级教程
macos
dzl843945 天前
mac 安装python
开发语言·python·macos
Bruce_Liuxiaowei5 天前
在 macOS 上通过 Docker 本地安装 OpenClaw 完整教程
macos·docker·容器·openclaw
阿捏利5 天前
详解Mach-O(十五)Mach-O __DATA_CONST
macos·ios·c/c++·mach-o
ShikiSuen5 天前
macOS 的 CpLk 中英切换卡顿的元凶在 InputMethodKit 本身
macos
xiayutian_c5 天前
如虎添翼-MacOS
macos