为什么 Ruby 找不到 Rake?

发布于 2024-09-08 01:05:15 字数 1385 浏览 3 评论 0原文

我昨天正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

热情消退 2024-09-15 01:05:15

看起来 rake 正在尝试从 Ruby 的系统版本 /usr/bin/rake 运行,而您在 /usr/local 中自定义安装了 Ruby。

  1. 确保您为正在使用的 Ruby 安装安装了 rake gem。
  2. 确保 rake 命令位于 $PATH 上的目录中。

which gem 应该从 /usr/local/bin 返回 ruby​​gems 安装。如果没有,那就是首先要解决的问题。然后您需要确保您的 /usr/local Ruby 安装中有 rake gem:

gem list | grep rake

应该告诉您该 gem 是否已安装。如果没有,请运行gem install rake

此时,which rake 应该指向 /usr/local 路径中的某个内容。如果不使用 find /usr/local | grep rake 找出您的 Ruby 安装保存 gem 可执行文件的位置,并将该目录添加到您的加载路径中。

顺便说一句,如果您使用自己安装的 Ruby,您可能会发现 rvmrbenv 有助于管理安装和 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.

  1. Make sure you have the rake gem installed for the Ruby installation you're using
  2. Make sure the 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:

gem list | grep rake

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 use find /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.

听你说爱我 2024-09-15 01:05:15

您只需要在 Gemfile 中添加 rake

gem 'rake'

You just need add rake on your Gemfile

gem 'rake'
一个人练习一个人 2024-09-15 01:05:15

我有类似的问题和“

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文