Problem with rake in a new app on rails 1.2.2

I’m trying to create a new app from scratch, with rails 1.2.2. I have
updated gem, rails, and rake all to their most recent versions. But I
still get this whenever I try to run any rake task, for example:

dhcp-123-193:~/Sites/foosball asa$ rake --tasks --trace
(in /Users/asa/Sites/foosball)
rake aborted!
undefined method gem' for main:Object /Users/asa/Sites/foosball/config/boot.rb:29 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire__’
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in require' /Users/asa/Sites/foosball/rakefile:4 /usr/local/rubygems/gems/rake-0.7.1/lib/rake.rb:1828:inload’
/usr/local/rubygems/gems/rake-0.7.1/lib/rake.rb:1828:in load_rakefile' /usr/local/rubygems/gems/rake-0.7.1/lib/rake.rb:1900:inrun’
/usr/local/rubygems/gems/rake-0.7.1/bin/rake:7
/usr/bin/rake:18:in `load’
/usr/bin/rake:18

I can run the console, and start the mongrel server, I just can’t use
rake.

Ideas?

Thanks,
Asa

On Feb 23, 2007, at 3:52 AM, Asa H. wrote:

I’m trying to create a new app from scratch, with rails 1.2.2. I have
updated gem, rails, and rake all to their most recent versions. But I
still get this whenever I try to run any rake task, for example:

dhcp-123-193:~/Sites/foosball asa$ rake --tasks --trace
(in /Users/asa/Sites/foosball)
rake aborted!
undefined method `gem’ for main:Object
/Users/asa/Sites/foosball/config/boot.rb:29

I can run the console, and start the mongrel server, I just can’t use
rake.

This is weird, since all of them execute boot.rb.

“gem” was introduced in a very recent RubyGems release (perhaps even
the last one). That release is installed because the server starts
just fine. So a posteriori it must be happening that rake is not
using that release for whatever reason.

Could you please investigate a bit that hypothesis? Can you for
instance check the shebang in script/server and see whether the
interpreter and rake live in different bin directories? Perhaps rake
uses a different interpreter?

– fxn

Xavier N. wrote:

I can run the console, and start the mongrel server, I just can’t use
rake.

This is weird, since all of them execute boot.rb.

“gem” was introduced in a very recent RubyGems release (perhaps even
the last one). That release is installed because the server starts
just fine. So a posteriori it must be happening that rake is not
using that release for whatever reason.

Could you please investigate a bit that hypothesis? Can you for
instance check the shebang in script/server and see whether the
interpreter and rake live in different bin directories? Perhaps rake
uses a different interpreter?

– fxn

Correct – rake was using /usr/bin/ruby, while everyone else was using
/usr/local/bin/ruby (or /usr/bin/env ruby).

Changed rake to use the right ruby, and changed it to “gem” from
“require_gem”, and all works fine with no errors.

Thanks!
Asa