【问题标题】:brew and gem both throws 'Permission denied' error whenever I run it每当我运行它时,brew 和 gem 都会抛出“权限被拒绝”错误
【发布时间】:2015-04-10 07:13:57
【问题描述】:

每当我运行“gem”或“brew”时都会发生这种情况:

/Library/Ruby/Site/2.0.0/rubygems/stub_specification.rb:75:in `initialize': Permission denied - /Library/Ruby/Gems/2.0.0/specifications/cocoapods-plugins-0.4.2.gemspec (Errno::EACCES)
from /Library/Ruby/Site/2.0.0/rubygems/stub_specification.rb:75:in `open'
from /Library/Ruby/Site/2.0.0/rubygems/stub_specification.rb:75:in `data'
from /Library/Ruby/Site/2.0.0/rubygems/stub_specification.rb:178:in `valid?'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:731:in `block in each_stub'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:723:in `block (2 levels) in each_gemspec'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:722:in `each'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:722:in `block in each_gemspec'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:721:in `each'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:721:in `each_gemspec'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:729:in `each_stub'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:748:in `stubs'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:705:in `_all'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:894:in `each'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1010:in `reverse_each'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1010:in `latest_specs'
from /Library/Ruby/Site/2.0.0/rubygems.rb:470:in `find_latest_files'
from /Library/Ruby/Site/2.0.0/rubygems.rb:983:in `load_plugins'
from /Library/Ruby/Site/2.0.0/rubygems/gem_runner.rb:81:in `<top (required)>'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/bin/gem:9:in `<main>'

我也安装了 cocoapods,当我检查文件夹时(/Library/Ruby/Gems/2.0.0/specifications/):

-rw-------   1 root  wheel  1599 Apr  9 22:41 cocoapods-plugins-0.4.2.gemspec
-rwxr-xr-x   1 root  wheel  1376 Jun 27  2014 cocoapods-trunk-0.1.3.gemspec
-rwxr-xr-x   1 root  wheel  1376 Sep  4  2014 cocoapods-trunk-0.1.4.gemspec
-rw-------   1 root  wheel  1290 Apr  9 22:41 cocoapods-trunk-0.6.0.gemspec
-rwxr-xr-x   1 root  wheel   980 Apr 27  2014 cocoapods-try-0.2.0.gemspec
-rwxr-xr-x   1 root  wheel   980 Jun 27  2014 cocoapods-try-0.3.0.gemspec
-rw-------   1 root  wheel   980 Apr  9 22:41 cocoapods-try-0.4.3.gemspec

似乎我没有 -r 读取权限,当我使用“sudo”时它们都运行良好,有人知道我做错了什么吗?无论是我安装 gem 还是 ruby​​ 的方式,对不起,我是 Ruby 和 Gems 的完整 n00b。我的 gem 命令位于 '/usr/bin/gem' 而我的 brew 命令位于 'usr/local/bin/brew' 非常感谢!

【问题讨论】:

    标签: ruby gem cocoapods homebrew permission-denied


    【解决方案1】:

    您似乎是从 root 帐户安装它并尝试从没有权限的用户运行。

    【讨论】:

    • 确实,谢谢@Łukasz Ostrowski!我实际上通过使用 RVM 解决了它,它变得更好更好。我使用的是系统原生默认红宝石。在我安装 RVM 并重新安装另一个 ruby​​ 2.1 后,一切正常!
    猜你喜欢
    • 2015-11-09
    • 1970-01-01
    • 2012-03-08
    • 2011-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-12
    相关资源
    最近更新 更多