<aside> 😭 前前后后折腾了好几天啊,前后试过了好几次 rvm 和 rbenv,最后还是用rbenv安装成功了,目前还没测试项目能不能跑起来,后面测试会再来更新。
P.S. 本文主要参考了:在M1 Macbook上优雅地安装Rbenv+Ruby
</aside>
brew --version
# 安装
brew install rbenv readline openssl
# 如果提示已经安装,就重装一下
brew reinstall rbenv readline openssl
将下面的内容加入到 ~/.zshrc
文件的末尾
# rbenv
export RBENV_ROOT=/opt/homebrew/opt/rbenv
export PATH=$RBENV_ROOT/bin:$PATH
eval "$(rbenv init -)"
# Use native openssl libraries for building
export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/homebrew/opt/[email protected]"
命令行中输入以下命令刷新,使环境变量生效
source ~/.zshrc
能稍微快一点
git clone <https://github.com/andorchen/rbenv-china-mirror.git> "$(rbenv root)"/plugins/rbenv-china-mirror