我试图使用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.
有人知道怎么解决这个问题吗?
当前回答
安装rbenv;
然后在~/的末尾加上eval "$(rbenv init -)"。Bash_profile(或~/.zshrc MacOS);
打开一个新终端,运行gem install ***将工作!
其他回答
给用户$whoami在这些文件夹中创建一些东西
sudo chown -R user /Library/Ruby/Gems/2.0.0
sudo gem update --system
sudo gem install (gemfile)
错误:当执行gem…(Gem:: FilePermissionError) 你没有写/Library/Ruby/Gems/2.6.0的权限
(2022方案) 这里已经添加了问题的详细原因
问题概述->该问题与ruby访问有关,M1 MAC自带ruby。我们没有被允许为我们的目的使用它。相反,我们安装了一个单独的ruby实例,并将其用于我们的目的。
下面的步骤帮助我解决了这个问题,希望这可能会有所帮助
我们不需要用rvn或chruby安装ruby。 我的解决方案使用自制程序来安装ruby。
打开终端 使用自制程序安装ruby
安装ruby
[用于重新安装]brew重装ruby
使用下面的命令检查ruby的路径 这红宝石 它应该安装在下面的路径 /usr/bin/ruby 将ruby路径更改为用户路径
检查您的系统使用了哪个shell
echo $0
-zsh
对于zshrc
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >>~/.zshrc . bin:$PATH
在bash
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >>~/~/.bashrc . bin:$PATH
退出并重新启动终端 用步骤5改变路径后 再次检查ruby的路径(执行步骤3 -请确保路径如下所示)
/usr/local/opt/ruby/bin/ruby
[如果您不退出并启动终端,将显示步骤4路径]
这一步可能并不适用于所有人,如果你安装了正确的Cocoapods版本,可以跳过第10和11步
检查安装的pod的版本
豆荚,版本
使用下面的命令卸载特定版本的Cocoapods
如果安装的版本是1.11.0
卸载cocoapods 1.11.0
安装特定版本的Cocoapods 安装cocoapods 1.11.0 将路径更改为Project目录cd {Project目录的路径} 在项目目录中安装捆绑程序
包安装
执行pod安装
正在安装
正如bobbdelsol所指出的,rehash对我来说很管用:
==> which ruby
/usr/bin/ruby
==> rbenv install 1.9.3-p551
Downloading ruby-1.9.3-p551.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p551.tar.bz2
Installing ruby-1.9.3-p551...
Installed ruby-1.9.3-p551 to /Users/username/.rbenv/versions/1.9.3-p551
==> which ruby
/Users/username/.rbenv/shims/ruby
==> which gem
/Users/username/.rbenv/shims/gem
==> gem install compass
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
==> ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
==> rbenv global 1.9.3-p551
==> ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
==> rbenv global 1.9.3-p551
==> rbenv rehash
==> ruby -v
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-darwin15.4.0]
==> gem install compass
Fetching: sass-3.4.22.gem (100%)
Fetching: multi_json-1.11.3.gem (100%)
Fetching: compass-core-1.0.3.gem (100%)
Fetching: compass-import-once-1.0.5.gem (100%)
Fetching: chunky_png-1.3.5.gem (100%)
Fetching: rb-fsevent-0.9.7.gem (100%)
Fetching: ffi-1.9.10.gem (100%)
Building native extensions. This could take a while...
Fetching: rb-inotify-0.9.7.gem (100%)
Fetching: compass-1.0.3.gem (100%)
Compass is charityware. If you love it, please donate on our behalf at http://umdf.org/compass Thanks!
Successfully installed sass-3.4.22
Successfully installed multi_json-1.11.3
Successfully installed compass-core-1.0.3
Successfully installed compass-import-once-1.0.5
Successfully installed chunky_png-1.3.5
Successfully installed rb-fsevent-0.9.7
Successfully installed ffi-1.9.10
Successfully installed rb-inotify-0.9.7
Successfully installed compass-1.0.3
9 gems installed
Installing ri documentation for sass-3.4.22...
Installing ri documentation for multi_json-1.11.3...
Installing ri documentation for compass-core-1.0.3...
Installing ri documentation for compass-import-once-1.0.5...
Installing ri documentation for chunky_png-1.3.5...
Installing ri documentation for rb-fsevent-0.9.7...
Installing ri documentation for ffi-1.9.10...
Installing ri documentation for rb-inotify-0.9.7...
Installing ri documentation for compass-1.0.3...
Installing RDoc documentation for sass-3.4.22...
Installing RDoc documentation for multi_json-1.11.3...
Installing RDoc documentation for compass-core-1.0.3...
Installing RDoc documentation for compass-import-once-1.0.5...
Installing RDoc documentation for chunky_png-1.3.5...
Installing RDoc documentation for rb-fsevent-0.9.7...
Installing RDoc documentation for ffi-1.9.10...
Installing RDoc documentation for rb-inotify-0.9.7...
Installing RDoc documentation for compass-1.0.3...
我对我的Mac进行了格式化,许多建议的解决方案对我不起作用。 对我来说有用的是这些正确顺序的命令:
安装自制程序: /usr/bin/ruby -e "$(curl - ssl https://raw.githubusercontent.com/Homebrew/install/master/install)" 安装Ruby: 编译安装ruby 安装指南: 须藤宝石安装指南针