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]
相关推荐
恋猫de小郭4 小时前
Compose Multiplatform 1.10 Interop views 新特性:Overlay 和 Autosizing
android·flutter·macos·kotlin·github·objective-c·cocoa
加油_Yeah6 小时前
Mac 科研/论文专用快捷键(Word + LaTeX + Finder) 与文件管理
macos·编辑器·word
ZhangBlossom6 小时前
Freqtrade 新人上手教程(macOS + Docker,无需 docker-compose)
macos·docker·容器
古城小栈6 小时前
Rust 交叉编译:MacOS ====> Linux (musl 静态编译)
linux·macos·rust
2501_915921436 小时前
360移动端性能监控实践QDAS-APM(iOS篇)
android·macos·ios·小程序·uni-app·cocoa·iphone
开开心心_Every1 天前
多端免费远程控制工具:4K流畅同账号直连
游戏·macos·微信·pdf·excel·语音识别·phpstorm
ha_lydms1 天前
在iCloud、Onedrive等云文件夹中开启超级右键菜单
macos·onedrive·icloud·超级右键·better365
我不是稻草人1 天前
Centos共享Mac文件
linux·macos·centos
不知疲倦的仄仄1 天前
HTTP解析/版本变化/TSL
网络协议·tcp/ip·macos
YuZou 邹宇1 天前
macOS 下 STM32CubeMX 无法访问 Desktop / 打不开 .ioc 文件的解决方法
stm32·嵌入式硬件·macos