生活随笔
收集整理的這篇文章主要介紹了
Ruby 版本升级
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
一、升級(jí)原因
在開(kāi)發(fā)shopify app的時(shí)候,提示我當(dāng)前的Ruby版本不支持(如下圖),所以需要升級(jí)Ruby。
由于Ruby 中的一些 Gem 依賴于 OpenSSL 庫(kù),所以更改 Ruby 版本,還需要安裝正確版本的 OpenSSL。
下面的升級(jí)過(guò)程會(huì)先安裝 OpenSSL 1.1,再安裝 Ruby 3.2。
二、升級(jí)過(guò)程
1、降級(jí) OpenSSL 版本
我當(dāng)前的 OpenSSL 版本為 3.2,存在不兼容的問(wèn)題,所以需要降到 1.1
brew list | grep openssl
openssl version
- 使用 Homebrew 安裝 OpenSSL 1.1
brew install openssl@3.0
brew link --force openssl@3.0
在
~/.bashrc、
~/.zshrc 或其他 shell 配置文件中添加如下行:
export PATH="/usr/local/opt/openssl@3.0/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@3.0/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3.0/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3.0/lib/pkgconfig"
- 使用
source命令立即應(yīng)用配置文件的更改 或 重啟終端
source ~/.bashrc
source ~/.zshrc
此時(shí),再次查看 OpenSSL 版本,應(yīng)為 1.1
2、升級(jí) Ruby 版本
ruby -v
brew install ruby@3.2
在
~/.bashrc、
~/.zshrc 或其他 shell 配置文件中添加如下行:
export PATH="/usr/local/opt/ruby/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"
- 使用
source命令立即應(yīng)用配置文件的更改 或 重啟終端
source ~/.bashrc
source ~/.zshrc
三、其他
1、查看當(dāng)前 Ruby 依賴的 OpenSSL 版本
ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
2、OpenSSL 版本不對(duì)相關(guān)報(bào)錯(cuò)
- ERROR: While executing gem ... (Gem::Exception)OpenSSL is not available. Install OpenSSL and rebuild Ruby or use non-HTTPS sources (Gem::Exception)
- Could not load OpenSSL. You must recompile Ruby with OpenSSL support.
- cannot load such file -- openssl (LoadError)
3、參考鏈接
https://*.com/questions/14845481/cannot-load-such-file-openssl-loaderror
https://www.jianshu.com/p/36a7a354d10f
總結(jié)
以上是生活随笔為你收集整理的Ruby 版本升级的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。