我试图使用gem install mygem或使用gem update——system更新RubyGems安装一个gem,它失败了,错误如下:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
有人知道怎么解决这个问题吗?
我试图使用gem install mygem或使用gem update——system更新RubyGems安装一个gem,它失败了,错误如下:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
有人知道怎么解决这个问题吗?
当前回答
该错误的原因是您没有以root用户登录终端。
如果你已经在终端类型的mac上启用了根用户
$ su
如果您没有root用户,您需要使用以下步骤启用它
From the Apple menu choose System Preferences…. From the View menu choose Users & Groups. Click the lock and authenticate as an administrator account. Click Login Options…. Click the “Edit…” or “Join…” button at the bottom right. Click the “Open Directory Utility…” button. Click the lock in the Directory Utility window. Enter an administrator account name and password, then click OK. Choose Enable Root User from the Edit menu. Enter the root password you wish to use in both the Password and Verify fields, then click OK.
更多内容请登录http://support.apple.com/kb/ht1528
在被困了几个小时后,至少它对我有用。
其他回答
这将以一种干净的方式修复MacOS Mojave和Catalina的问题:
brew install ruby
然后将GEM_HOME设置为您的用户目录。终端:
Bash: echo '#安装Ruby Gems到~/ Gems ' >> ~/.bashrc echo 'export GEM_HOME=$HOME/gems' >> ~/.bashrc echo 'export PATH=$HOME/gems/bin:$PATH' >> ~/.bashrc . txt 源~ / . bashrc 如果在Zsh上: echo '#安装Ruby Gems到~/ Gems ' >> ~/.zshrc echo 'export GEM_HOME=$HOME/gems' >> ~/.zshrc echo 'export PATH=$HOME/gems/bin:$PATH' >> ~/.zshrc . txt 源~ / . zshrc
你可以使用:gem install cocoapods——pre——user
cd /图书馆/ Ruby /珠宝/ 2.0.0
开放。
右击获取信息
点击锁定
地方的密码
让一切都能读能写。
在使用下面我的原始答案之前,试试nathanwhy的答案。他推荐的——user-install应该可以达到同样的目的,而不必破坏.bash_profile或确定Ruby版本。
如果您不关心特定的ruby版本,您可以跳过繁重的ruby环境管理器选项,只需将这些行添加到~/.bash_profile:
export GEM_HOME="$HOME/.gem/ruby/2.0.0"
export GEM_PATH="$HOME/.gem/ruby/2.0.0"
路径是从gem env的原始输出中窃取的:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/.../2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-14
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/mylogin/.gem/ruby/2.0.0 # <---- This line, right here. -----
- /System/Library/.../usr/lib/ruby/gems/2.0.0
...
不需要进行任何操作,并且您可以使用已经安装好的Ruby,这是Apple提供的。
该错误的原因是您没有以root用户登录终端。
如果你已经在终端类型的mac上启用了根用户
$ su
如果您没有root用户,您需要使用以下步骤启用它
From the Apple menu choose System Preferences…. From the View menu choose Users & Groups. Click the lock and authenticate as an administrator account. Click Login Options…. Click the “Edit…” or “Join…” button at the bottom right. Click the “Open Directory Utility…” button. Click the lock in the Directory Utility window. Enter an administrator account name and password, then click OK. Choose Enable Root User from the Edit menu. Enter the root password you wish to use in both the Password and Verify fields, then click OK.
更多内容请登录http://support.apple.com/kb/ht1528
在被困了几个小时后,至少它对我有用。