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]
相关推荐
霸道流氓气质5 小时前
RabbitMQ 延迟队列与死信队列:原理、实现与实战
分布式·rabbitmq·ruby
Architect_Lee14 小时前
mac快速安装mysql
数据库·mysql·macos
User_芊芊君子15 小时前
STT + LLM + TTS:用一条流水线搓了个中英双向翻译助手
ide·macos·xcode
凤山老林1 天前
在 Apple 芯片的 Mac 上通过 VMware Fusion 使用 Windows 11
windows·macos·vmware·虚拟机
c&0xff001 天前
mac通过网线连接树莓派
macos
孙启超2 天前
Token太贵自己写了一个mac版开源AI编程工具
人工智能·macos·开源·llm·agent·ai编程·ai应用开发
2601_965798472 天前
Launch Your Wellness App Fast: The Truth About Meditation Source Code
前端·macos·ios·objective-c·cocoa
2501_915909063 天前
全面解析iOS应用上架到App Store的完整流程与关键注意事项
android·macos·ios·小程序·uni-app·cocoa·iphone
2501_915918413 天前
免 Xcode 开发 iOS,工具链替代方案与编译、签名、安装
ide·vscode·macos·ios·个人开发·xcode·敏捷流程
Architect_Lee4 天前
mac安装多个tomcat
macos