繁体   English   中英

如何在Rails 5.0.0上修复捆绑安装“ nio4r错误”

[英]How to fix a bundle install “nio4r error” on Rails 5.0.0

确切的错误是:

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.

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

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

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

brew update 

bundle update

我刚才遇到了同样的错误。.就我而言,我已经通过以下软件包安装了Ruby: https : //www.brightbox.com/blog/2017/01/13/ruby-2-4-ubuntu-packages /

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

就我而言: sudo apt-get install ruby2.4-dev对我sudo apt-get install ruby2.4-dev

安装后,我能够编译gem: nio4r

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

此路径:

/Users/lukeplourde/.rbenv/...

说明您正在使用rbenv来管理Ruby。

在这种情况下,您永远都不会出现权限错误。 得到一个权限错误,这一事实有力地表明,在某些时候你安装的东西,大概nio4r,成rbenv管理红宝石使用sudo

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

rbenv的文档专门说不要使用sudo

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

要解决该问题,只需运行:

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命令,并适当调整文件/目录许可权,您应该可以解决此问题。

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

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

这为我解决了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM