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

<snip>

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