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]
相关推荐
为什么不问问神奇的海螺呢丶20 小时前
n9e categraf rabbitmq监控配置
分布式·rabbitmq·ruby
皮卡车厘子1 天前
Mac 挂载目录
macos
良逍Ai出海1 天前
在 Windows & macOS 上安装 Claude Code,并使用第三方 Key 的完整教程
windows·macos
热爱生活的五柒1 天前
linux/mac/wsl如何使用claude code,并配置免费的硅基流动API?(官方的需要付费订阅)
linux·运维·macos
胖胖大王叫我来巡山1 天前
mac本地安装DataEase桌面版
macos
奋斗者1号1 天前
OpenClaw 部署方式对比:云端、WSL、Mac 本机、Ubuntu 虚拟机(2026年2月最新主流实践)
linux·ubuntu·macos
玉梅小洋1 天前
Android SDK 安装指南(MacOS 和 Windows)
android·windows·macos·sdk
2501_916007471 天前
没有 Mac 用户如何上架 App Store,IPA生成、证书与描述文件管理、跨平台上传
android·macos·ios·小程序·uni-app·iphone·webview
胖胖大王叫我来巡山1 天前
Mac通过源码安装部署SQLBOT
macos
June bug2 天前
【领域知识】广告全链路测试
macos·objective-c·cocoa