【问题标题】:How to fix a bundle install "nio4r error" on Rails 5.0.0如何在 Rails 5.0.0 上修复捆绑安装“nio4r 错误”
【发布时间】:2017-07-27 21:22:52
【问题描述】:

确切的错误是:

An error occurred while installing nio4r (1.2.1), and bundler cannot continue. Make sure that 'gem install nio4r -v '1.2.1'' succeeds before bundling.

这是一个踪迹:

Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Fetching dependency metadata from https://rubygems.org/
Using rake 12.0.0
Using concurrent-ruby 1.0.5
Using i18n 0.8.1
Using minitest 5.10.1
Using thread_safe 0.3.6
Using builder 3.2.3
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using rack 2.0.1
Installing nio4r 1.2.1 with native extensions

Errno::EACCES: Permission denied @ rb_sysopen - /Users/lukeplourde/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nio4r-1.2.1/.gitignore
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using arel 7.1.4
Using byebug 9.0.6
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using method_source 0.8.2
Using thor 0.19.4
Using debug_inspector 0.0.2
Using ffi 1.9.17
Using multi_json 1.12.1
Using rb-fsevent 0.9.8
Using puma 3.7.0
Using bundler 1.12.5
Using sass 3.4.23
Using tilt 2.0.6
Using sqlite3 1.3.13
Using turbolinks-source 5.0.0
Using tzinfo 1.2.2
Using nokogiri 1.7.0.1
Using rack-test 0.6.3
Using sprockets 3.7.1
An error occurred while installing nio4r (1.2.1), and Bundler cannot continue.
Make sure that `gem install nio4r -v '1.2.1'` succeeds before bundling.

【问题讨论】:

  • 你能把整个日志输出吗?
  • 将整个日志添加到您的问题中,并尝试在单独的 wa 中安装 nio4r gem,否则从 ruby​​gems.org 下载并进行安装。
  • 您应该尝试通过运行:gem install nio4r -v 1.2.1 来安装 gem nio4r 并查看问题所在。
  • @DungPham 我尝试通过命令行安装 gem 并将其放入我的 Gemfile 中,但没有成功。
  • 如您所见.. 您的日志中有 Permission Denied 错误。你能检查错误消息中指示的文件夹的权限吗?

标签: ruby-on-rails ruby rubygems bundler ruby-on-rails-5


【解决方案1】:

如果有人在寻找这个,我已经更新了我的计算机并更新了命令行工具。我需要同意 XCode 许可证。

Error: You have not agreed to the Xcode license. Please resolve this
 by running:   sudo xcodebuild -license accept

这为我解决了问题。

【讨论】:

    【解决方案2】:

    我通过运行以下命令解决了这个问题。

    bundle config build.nio4r --with-cflags="-std=c99"
    bundle
    

    【讨论】:

    • 我的冠军,我的英雄。所有科技梦想成真的地方!我爱你。
    • 它有效!但为什么?非常感谢您的解释:)
    【解决方案3】:

    我能够通过以下方式解决问题:

    brew update 
    

    bundle update
    

    【讨论】:

    • 在 Archlinux 上也为我工作过
    【解决方案4】:

    这条路径:

    /Users/lukeplourde/.rbenv/...
    

    表明你正在使用 rbenv 来管理你的 Ruby。

    在这种情况下,您绝不应该出现权限错误。您正在收到权限错误这一事实强烈表明,您在某个时候使用sudo 在 rbenv 管理的 Ruby 中安装了一些东西,可能是 nio4r。

    当您使用sudo 时,您会暂时将您的权限提升到系统的root 用户的权限,并且所有保存的文件都将拥有该用户的读/写设置和所有权。这绝对不是你想要的。

    rbenv's documentation 明确表示不要使用sudo

    您不需要 sudo 来安装 gem。通常,Ruby 版本将由您的用户安装和编写。安装 gems 不需要额外的权限。

    要解决问题,只需运行:

    sudo chown -R lukeplourde ~/.rbenv
    

    并且chown 将遍历~/.rbenv 目录中的所有目录,并将所有子文件和目录的所有权更改回您。

    知道何时使用sudo 需要具备 Ruby 环境的经验和知识、您当前的设置以及您打算做什么。不过,一般来说,如果您的 rbenv 设置为使用您安装的 Ruby,那么在使用 gem 时,您不想使用任何 sudo 命令。如果您在 Mac OS 上使用 sudo 和 rbenv 以及您安装的 Ruby,那么在按下 Return 之前请三思而后行,因为这可能不是您想要做的。

    而且,如果您使用的是 RVM 或 Homebrew 管理的 Ruby,上述关于使用 sudo 的警告也适用。 sudo 通常不是您想要的第一种方法。他们官方网站上的文档是您了解该做什么的最佳信息来源。


    您是否重置了文件的所有权?

    所有权没有改变。

    大多数时候,权限问题的根源在于两件事:

    • 所有权
    • 访问标志

    chown 更改文件或目录的所有权,并可选择允许我们更改所有者的组。如果您不是系统的所有者,并且/或者不在该组中,那么您能够访问它的机会就会下降。

    chmod 更改所有者、他们的组和/或机器上其他所有人的文件或目录的访问权限。

    有问题的.gitignore 文件应归您所有,并拥有-rw-r--r-- 的权限。如果不是,您需要设置它们。在命令行使用man chmodman chown研究chmodchown命令并适当调整文件/目录权限,您应该能够解决问题。

    【讨论】:

    • 没有sudo命令,nio4r的错误还是一样。
    • 您是否重置了文件的所有权?
    • 所有权没有变化。
    • 通常使用chown 会解决权限问题,因为权限标志应该默认为可用的。我将在答案中添加更多关于如何重置权限读/写/执行标志的信息。
    【解决方案5】:

    我刚才遇到了同样的错误。在我的例子中,我通过包安装了 ruby​​:https://www.brightbox.com/blog/2017/01/13/ruby-2-4-ubuntu-packages/

    但是,我还没有安装ruby-dev 包。

    就我而言:sudo apt-get install ruby2.4-dev 为我工作。

    安装后我可以编译 gem:nio4r

    我认为你必须安装一些包ruby-dev => sudo apt-get install ruby-dev

    【讨论】:

    • 我应该在 MacOS Sierra 10.12.3 上提到这一点
    • /Users/ 是判断它是 Mac OS 系统还是常规 *nix 的关键。 Mac OS 不使用apt-get
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-28
    • 2021-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多