【问题标题】:Why do I get "ERROR: While executing gem ... (Gem::FilePermissionError)"?为什么我会收到“错误:执行 gem ... (Gem::FilePermissionError)”?
【发布时间】:2013-08-21 17:23:29
【问题描述】:

uninstalled RVM 并使用single user installation 重新安装:

\curl -L https://get.rvm.io | bash -s stable

当我执行bundle 时,它会提示:

Enter your password to install the bundled RubyGems to your system:

我尝试使用“ERROR: While executing gem … (Gem::FilePermissionError)”中的答案,但没有解决。

然后,在尝试手动安装 gem 时,我得到了:

Gem::InstallError: nokogiri requires Ruby version >= 1.9.2.
An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.

然后运行 ​​gem install nokogiri -v '1.6.0' 返回:

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.

我检查了 SO 上所有类似的帖子,但他们没有解决问题。我错过了什么?

【问题讨论】:

  • 从您的错误消息中(nokogiri 需要 Ruby 版本 >= 1.9.2。)您有一个较旧的 Ruby 版本。检查您的 Ruby 版本。
  • 谢谢,这帮助我解决了问题!更新 ruby​​ 版本后,我不得不做一些手动 gem 安装。把它写成答案,我会接受。

标签: ruby permissions gem rvm bundler


【解决方案1】:

确保使用以下命令更新您的系统 ruby​​gems:sudo gem update --system --no-user-install

bundler 使用它来代替您的本地版本,并且您的 bundler 版本可能与您的系统 ruby​​gems 不兼容。

它对我有用;)

【讨论】:

  • 这解决了我通过 rbenv 得到的相同错误。谢谢!
【解决方案2】:

安装 RVM 后,您还需要几个步骤:

  1. 将 RVM 加载到当前 shell:

    source ~/.rvm/scripts/rvm
    

    如果您关闭并再次打开终端,通常不需要这样做

  2. 安装红宝石:

    rvm install ruby
    
  3. 使用红宝石:

    rvm use ruby
    

最后一步非常重要,因为您的错误消息提到系统红宝石不是由 RVM 控制的。

【讨论】:

  • \curl -sSL get.rvm.io | bash -s 稳定。在运行脚本 rvm 之前运行此注释。
猜你喜欢
  • 2013-09-07
  • 1970-01-01
  • 2011-09-01
  • 1970-01-01
  • 2018-11-16
  • 2019-08-20
相关资源
最近更新 更多