为什么 Ruby 找不到 Rake?
我昨天正在使用 Rails 3 beta gem,但回到了 2.3.8,并且在清理系统 gem 后,我尝试运行一个简单的 Rake 任务并得到了这个:
Peleliu:haml jayfallon$ sudo rake install /Library/Ruby/Site/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rake (>= 0) (Gem::LoadError) from /Library/Ruby/Site/1.8/rubygems.rb:214:in `activate' from /Library/Ruby/Site/1.8/rubygems.rb:1082:in `gem' from /usr/bin/rake:18
我不确定它是否与我的路径有关是否感到无聊。
RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0] - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8 - RUBY EXECUTABLE: /usr/local/bin/ruby - EXECUTABLE DIRECTORY: /usr/local/bin - RUBYGEMS PLATFORMS: - ruby - x86-darwin-10 - GEM PATHS: - /usr/local/lib/ruby/gems/1.8 - /Users/jayfallon/.gem/ruby/1.8 - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - :sources => ["http://gems.rubyforge.org/", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gemcutter.org/"] - REMOTE SOURCES: - http://gemcutter.org/
I was using the Rails 3 beta gem yesterday but went back to 2.3.8, and, after cleaning the system gems, I was trying to run a simple Rake task and got this:
Peleliu:haml jayfallon$ sudo rake install /Library/Ruby/Site/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rake (>= 0) (Gem::LoadError) from /Library/Ruby/Site/1.8/rubygems.rb:214:in `activate' from /Library/Ruby/Site/1.8/rubygems.rb:1082:in `gem' from /usr/bin/rake:18
I am not sure if it has to do with my path being borked or not.
RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0] - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8 - RUBY EXECUTABLE: /usr/local/bin/ruby - EXECUTABLE DIRECTORY: /usr/local/bin - RUBYGEMS PLATFORMS: - ruby - x86-darwin-10 - GEM PATHS: - /usr/local/lib/ruby/gems/1.8 - /Users/jayfallon/.gem/ruby/1.8 - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - :sources => ["http://gems.rubyforge.org/", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gems.github.com", "http://gemcutter.org/"] - REMOTE SOURCES: - http://gemcutter.org/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来 rake 正在尝试从 Ruby 的系统版本
/usr/bin/rake
运行,而您在/usr/local
中自定义安装了 Ruby。which gem
应该从/usr/local/bin
返回 rubygems 安装。如果没有,那就是首先要解决的问题。然后您需要确保您的/usr/local
Ruby 安装中有 rake gem:应该告诉您该 gem 是否已安装。如果没有,请运行
gem install rake
。此时,
which rake
应该指向/usr/local
路径中的某个内容。如果不使用find /usr/local | grep rake
找出您的 Ruby 安装保存 gem 可执行文件的位置,并将该目录添加到您的加载路径中。顺便说一句,如果您使用自己安装的 Ruby,您可能会发现 rvm 或 rbenv 有助于管理安装和 gem。
It looks like rake is trying to run from
/usr/bin/rake
, the system version of Ruby, while you have a custom install of Ruby in/usr/local
.rake
command is in a directory on your $PATH.which gem
should return the rubygems install from/usr/local/bin
. If not, that's the first problem to solve. Then you want to make sure you have the rake gem in your/usr/local
Ruby installation:should tell you if the gem is installed. If not, run
gem install rake
.At this point,
which rake
should point to something in your/usr/local
path. If it doesn't usefind /usr/local | grep rake
to figure out where your Ruby install is keeping gem executables and add that directory to your loadpath.As a side note, if you're using your own install of Ruby, you might find rvm or rbenv helpful for managing installs and gems.
您只需要在 Gemfile 中添加 rake
You just need add rake on your Gemfile
我有类似的问题和“
I had similar problem and "A Tale of Abort Traps (or Always Question Your Assumptions)" helped.