- 執(zhí)行
sudo gem install bundler
- 報(bào)錯(cuò):
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
- 分析:
指定的ruby路徑不對(duì),應(yīng)當(dāng)使用更新版本的ruby - 解決方式:
- 安裝rbenv
- 指定使用rbenv的gem來執(zhí)行
- 安裝rbenv
$ brew install rbenv
- 安裝ruby
$ rbenv install -l
2.6.9
2.7.5
3.0.3
3.1.1
jruby-9.3.3.0
mruby-3.0.0
rbx-5.0
truffleruby-22.0.0.2
truffleruby+graalvm-22.0.0.2
$ rbenv install 3.1.1
- 指定ruby 版本
$ rbenv global 3.1.1
$ rbenv rehash
- 查找gem路徑
$ rbenv which gem
~/.rbenv/versions/3.1.1/bin/gem
- 添加相關(guān)路徑到PATH中
$ export PATH="$HOME/.rbenv/versions/3.1.1/bin:$PATH"
也可以寫到.zshrc里面啦,
當(dāng)然你還可以再diao一點(diǎn),直接用full path來執(zhí)行。
-
接著執(zhí)行bundle install
done