Ruby gem环境问题 - LoadError:没有这样的文件加载 - 机器人 [英] Ruby gem environment issue - LoadError: no such file to load -- robots
问题描述
我正在尝试使用海葵宝石编写履带,这需要机器人宝石。无论出于何种原因,机器人绝对不会包括在内。这里是我的一些环境信息:
I'm attempting to write a crawler using the anemone gem, which requires the robots gem. For whatever reason, robots absolutely will not include. Here is some of my environment info:
$ gem list -d robots
*** LOCAL GEMS ***
robots (0.10.1)
Author: Kyle Maxwell
Homepage: http://github.com/fizx/robots
Installed at: /usr/local/lib/ruby/gems/1.9.1
Simple robots.txt parser
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [x86_64-darwin10.7.0]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.9.1
- /Users/ryan/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
$ gem which robots
/usr/local/lib/ruby/gems/1.9.1/gems/robots-0.10.1/lib/robots.rb
任何想法?所有其他宝石加载正确,我从来没有遇到过这个问题。请注意,我使用的是Ruby 1.9版本,因此需要rubygems。添加
Any ideas? All other gems load correctly, I've never had this problem before. Note that I am using ruby version 1.9, so rubygems is implicitly required. Adding
require 'rubygems'
...到一个脚本的前面会返回false,因为该文件已经包含在内,并且不利于这种情况。任何想法?
...to the front of a script returns false, since the file is already included, and does not help the situation. Any ideas?
编辑:发布失败代码的示例。请注意,返回false的rubygems并不意味着rubygems无法加载 - 而是它已经被加载。看到这篇文章: http://www.ruby-forum.com/topic/157442
Posting examples of failing code. Please note that rubygems returning false does not mean rubygems cannot load - rather that it has already been loaded. See this post: http://www.ruby-forum.com/topic/157442
$ irb
irb(main):001:0> require 'rubygems'
=> false
irb(main):002:0> require 'active_record'
=> true
irb(main):003:0> require 'mechanize'
=> true
irb(main):004:0> require 'robots'
LoadError: no such file to load -- robots
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from (irb):4
from /usr/local/bin/irb:12:in `<main>'
irb(main):005:0>
推荐答案
它看起来像是创建了错误的gem权限; 在github上为此打开了一个bug 。
It looks like the gem has been created with the wrong permissions; there's a bug opened for this on github.
使用
sudo chmod a+r /usr/local/lib/ruby/gems/1.9.1/gems/robots-0.10.1/lib/robots.rb
应该修复它,但要小心其他许可的问题。您可能会更好
should fix it, but watch out for other permission issues. You might be better with
sudo chmod -R a+r /usr/local/lib/ruby/gems/1.9.1/gems/robots-0.10.1
以递归方式使gem中的所有文件可读。
to recursively make all the files in the gem readable.
-rw -rw ----
,所以任何使用本地安装的rvm或类似地方安装gem作为本地用户的用户都不会受到此影响。
The robots.rb
file (and some others) is being installed with the permissions -rw-rw----
, so anyone using a local install of rvm or similar where gems are installed as the local user won't have been affected by this.
这篇关于Ruby gem环境问题 - LoadError:没有这样的文件加载 - 机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!