开发者

Rake can't be found

hey i played around with bundler and some gems and now i can't use rake anymore

if i do a simple db:migrate i get this error:

mac:app antpaw$ rake db:migrate
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:335:in `bin_path': can't find executable rake for rake-0.8.7 (Gem::Exception)
 from <internal:gem_prelude>:282:in `method_missing'
 from /usr/local/bin/rake:19:in `<main>'

but rake is listed if i do gem list. im using the rails 3.0.0beta4, bundler 1.0.0.beta.5, and ruby 1.9.2dev.

EDIT posted my export

mac:trickpipe antpaw$ export
declare -x Apple_PubSub_Socket_Render="/tmp/launch-2GMaKT/Render"
declare -x COMMAND_MODE="unix2003"
declare -x DISPLAY="/tmp/launch-5RguhF/:0"
declare -x HOME="/Users/antpaw"
declare -x LC_CTYPE="UTF-8"
declare -x LOGNAME="antpaw"
declare -x OLDPWD="/Users/antpaw"
declare -x PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin"
declare -x PWD="/Volumes/Work HD/localhost/trickpipe"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_AUTH_SOCK="/tmp/launch-N13Ivn/Listeners"
declare -x TERM="xterm-color"
declare -x TERM_PROGRAM="Apple_Terminal"
declare -x TERM_PROGRAM_VERSION="272"
declare -x TMPDIR="/var/folders/-K/-Kf7svFPHrKmLqMXKAGLuU+++TI/-Tmp-/"
declare -x USER="antpaw"
declare -x __CF_USER_TEXT_ENCODING="0x1F5:0:开发者_StackOverflow社区0"
mac:trickpipe antpaw$ which ruby
/usr/local/bin/ruby
mac:trickpipe antpaw$ ruby -v
ruby 1.9.2dev (2010-07-02 revision 28524) [x86_64-darwin10.2.0]

Ok i tried it out, look how the error msg is changing:

mac:trickpipe antpaw$ export GEM_HOME="/usr/local/lib/ruby/gems"
mac:trickpipe antpaw$ rake about
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:335:in `bin_path': can't find executable rake for rake-0.8.7 (Gem::Exception)
    from <internal:gem_prelude>:282:in `method_missing'
    from /usr/local/bin/rake:19:in `<main>'
mac:trickpipe antpaw$ export GEM_PATH="/usr/local/lib/ruby/gems"
mac:trickpipe antpaw$ rake about
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rake (>= 0) (Gem::LoadError)
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:214:in `activate'
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:1082:in `gem'
    from <internal:gem_prelude>:213:in `push_gem_version_on_load_path'
    from <internal:gem_prelude>:16:in `gem'
    from /usr/local/bin/rake:18:in `<main>'
mac:trickpipe antpaw$ 

now with rvm:

mac:trickpipe antpaw$ rake about
(in /Volumes/Work HD/localhost/rails_app)
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:30: warning: already initialized constant RAKEVERSION
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:402: warning: already initialized constant EMPTY_TASK_ARGS
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:450: warning: already initialized constant EMPTY
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:958: warning: already initialized constant RUBY_EXT
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:962: warning: already initialized constant RUBY
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:1031: warning: already initialized constant LN_SUPPORTED
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:1240: warning: already initialized constant ARRAY_METHODS
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:1243: warning: already initialized constant MUST_DEFINE
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:1247: warning: already initialized constant MUST_NOT_DEFINE
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:1251: warning: already initialized constant SPECIAL_RETURN
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:1257: warning: already initialized constant DELEGATING_METHODS
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:1561: warning: already initialized constant DEFAULT_IGNORE_PATTERNS
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:1567: warning: already initialized constant DEFAULT_IGNORE_PROCS
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:1604: warning: already initialized constant FileList
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:1630: warning: already initialized constant EARLY
/Users/antpaw/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rake.rb:1960: warning: already initialized constant DEFAULT_RAKEFILES
DEPRECATION WARNING: Calling a method in Rails::Application is deprecated, please call it directly in your application constant Trickpipe::Application. (called from method_missing at /Users/antpaw/.rvm/gems/ruby-1.9.2-rc2/bundler/gems/rails-edb5401/railties/lib/rails/application.rb:77)
rake aborted!
stack level too deep

(See full trace by running task with --trace)


Just an FYI if you used macports to install ruby 1.9.2 I had an issue like so:

/opt/local/lib/ruby1.9/1.9.1/rubygems.rb:340:in `bin_path': can't find executable rake for rake-0.8.7 (Gem::Exception)
from /opt/local/bin/rake:19:in `<main>'

The fix is to go into /opt/local/lib/ruby1.9/gems/1.9.1/specifications and delete "rake.gemspec"

That's it... took forever to find that but, it worked fine


I'm pretty sure that you didn't setup your path environment properly. /usr/local/lib/ruby/site_ruby/1.9.1/ is the default package folder of the RUby interpreter shipped with Mac OS X -- crap. When you're saying that you (assume to) use Ruby 1.9.2dev this path is wrong. Please drop export in the shell and post the result. Additionally please post you install-/pathes of Ruby 1.9.2dev and your bundled folder.

Edit 1:

Okay, quickfix for your issue: export GEM_HOME="/path/where/your/gems/reside" and optionally export GEM_PATH="/path/where/your/gems/reside" and optionally export PATH="/path/where/your/gems/reside:$PATH". Only in this order! Try one, when it still doesn't work proceed with the next export.

Note that this should fix your problem, but to make a Bundler environment work with rails f.e. you must change your Rails app's config to explicitly use your custom BUndler gem environment. I read some time ago that Rails3 will include options for that; when this is the case (I dunno Rails3) check your those commands.

P.s: Put Bundler aside and use RVM instead. It's much more powerful, more mature and allows for far more flexibility (especially when dealing with multiple interpreters in conjunction with gemsets).


I got the same problem with RVM ("warning: already initialized constant RAKEVERSION") and so on.

I'm using a Gemset ("rails") to do my dev, but I noticed that my BUNDLE_PATH was pointing not to this gemset (.rvm/gems/ruby-1.9.2-p0@rails); instead, it was pointing to the global one (.rvm/gems/ruby-1.9.2-p0).

I fixed the BUNDLE_PATH to use the rails Gemset and rake is now correctly worked. Hope it helps.


it's a bug in 1.9.2p0 http://betterlogic.com/roger/2010/11/ruby-1-9-2-rake-woe/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜