安装 Nokogiri 时出现问题
我正在关注本教程,我已经到达需要安装这些 gem 的地方:
gem 'rails', '3.0.3'
gem 'sqlite3-ruby', :require => 'sqlite3'
group :development do
gem 'rspec-rails', '2.0.1'
end
group :test do
gem 'rspec', '2.0.1'
gem 'webrat', '0.7.1'
end
然后我就这样做了a:
bundle install
但是终端给了我这个:
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.2)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.26)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.16)
Using actionmailer (3.0.3)
Using arel (2.0.9)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.12)
Using diff-lcs (1.1.2)
Installing nokogiri (1.4.4) /Library/Ruby/Site/1.8/rubygems/installer.rb:574:in `initialize': Permission denied - /Library/Ruby/Gems/1.8/gems/nokogiri-1.4.4/.autotest (Errno::EACCES)
from /Library/Ruby/Site/1.8/rubygems/installer.rb:574:in `open'
我对此做了很多研究,我发现一些人也遇到了同样的问题: http://taleswithrails.com/2011/01 /error-gemfile-could-not-find-gem-webrat/
我已经阅读了安装指南: http://nokogiri.org/tutorials/installing_nokogiri.html
但我无法:
sudo port ...
或
sudo apt-get ...
工作。他们返回“未找到命令”。所以我认为我这里有两个问题...
1) Nokogiri 没有正确安装,我不知道为什么。我也不知道我正在运行的机器是什么“风格”(换句话说,哪个 Nokogiri 安装说明适合我的设置)。
2)这些命令在我的系统(OSX 10.6)上不起作用,我不知道为什么。我已经阅读了 Macports 和 libxml2,但我有点不清楚它是什么以及我需要做什么(或者它是否适用于我)。我确实尝试安装 macports,但我没有 Xcode,这是必需的。但我不是“mac 开发者”。这是我唯一的选择吗?
I'm following this tutorial and I've come to where I need to install these gems:
gem 'rails', '3.0.3'
gem 'sqlite3-ruby', :require => 'sqlite3'
group :development do
gem 'rspec-rails', '2.0.1'
end
group :test do
gem 'rspec', '2.0.1'
gem 'webrat', '0.7.1'
end
Then I do a:
bundle install
But terminal gives me this:
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.2)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.26)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.16)
Using actionmailer (3.0.3)
Using arel (2.0.9)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.12)
Using diff-lcs (1.1.2)
Installing nokogiri (1.4.4) /Library/Ruby/Site/1.8/rubygems/installer.rb:574:in `initialize': Permission denied - /Library/Ruby/Gems/1.8/gems/nokogiri-1.4.4/.autotest (Errno::EACCES)
from /Library/Ruby/Site/1.8/rubygems/installer.rb:574:in `open'
I've done a bunch of research on this and I've found some people who had the same problems:
http://taleswithrails.com/2011/01/error-gemfile-could-not-find-gem-webrat/
And I've read the installation guide: http://nokogiri.org/tutorials/installing_nokogiri.html
But I can't get:
sudo port ...
or
sudo apt-get ...
To work. They return with "command not found". So I think I have two issues here...
1) Nokogiri is not installing properly and I'm not sure why. I also don't know what "flavor" of machine I'm running (in other words, which of the Nokogiri installation instructions pertains to my setup).
2) Those commands don't work on my system (OSX 10.6) and I'm not sure why. I've read up on Macports and libxml2 but it's a little unclear to me what it is and what I need to do (or if it's even applicable to me). I did try installing macports, but I don't have Xcode, which is required. But I'm not a "mac developer". Is this my only option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以看起来你同时遇到了几个不同的问题,你需要一一解决它们。
首先,您可以在终端中运行
gem install Nokogiri
,然后尝试在 IRB 中使用它来检查它是否有效?然后,您应该知道 sudo apt-get 是使用 aptitude 获取软件的命令,您不会在 Mac 上使用它,它用于 Linux。和
sudo port
使用macports
安装 nokogiri,只有安装了 Macports 才有效。我建议您获取 Homebrew 并
在本地运行后 使用
brew install nokogiri
在 ruby 脚本中,然后担心 Rails。权限被拒绝错误可能是因为您在不应该使用的地方使用了一些 sudo,在 Mac 上您真的不应该使用该命令。如果您需要安装 ruby gems,请查看 RVM,它可以让您安装“大多数”gems,而无需 sudo
So it seems like you have several different problems going on at the same time and you need to sort them out one by one.
First, can you run
gem install Nokogiri
in your terminal, and then try using it in IRB to check that it works?Then, you should that
sudo apt-get
is the command for getting software using aptitude which you will NOT be using on your mac, it is used for Linux. andsudo port
usesmacports
to install nokogiri, which will only work if you have Macports installed.I would recommend getting Homebrew and using
brew install nokogiri
once you have it working locally in a ruby script, then worry about rails.
The permission denied error is probably because you have been using some sudo's where you should not be, on a mac you really should never be using that command. If you need to install ruby gems, look into RVM which will let you install 'most' gems without needing to sudo