Thursday, May 28, 2009

can't activate rails (= 2.2.2, runtime)

Is your computer being uncooperative when you try to run rake or some other ruby or rails software?
$rake
rake aborted!
can't activate rails (= 2.2.2, runtime), already activated rails-2.3.2
From my experience, this probably means that you have installed other versions of rails or some other conflicting gems in your local gem repository (~/.gem).

How did this happen? Well, you probably installed those gems without using the sudo command.

When you install ruby gems as a user without root or admin privileges, ruby will warn you that you are not installing those gems for the entire system.
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/nels.nelson/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
Don't worry -- you can recover from this misstep. Those locally installed gems will probably interfere with gems that have been installed system-wide. No problem.

Remove them!
$rm -rf ~/.gem/ruby/*/cache/*
$rm -rf ~/.gem/ruby/*/doc/*
$rm -rf ~/.gem/ruby/*/gems/*
$rm -rf ~/.gem/ruby/*/specifications/*
BUT WAIT!!

Don't just delete stuff because you are told to. Examine those directories, and make sure that you have already installed those gems for the entire system. If not you will have to reinstall them for the entire system if you still need to, and if you have admin privileges (you can use the sudo command).
$sudo gem install <your gem>
Now that you have removed those gems from your user-local gem repository, you should be able to actually reinstall them. This means that you should make a list of what you had previously installed.

1 comment:

Unknown said...

I had the same issue and fixed the problem like this :

As far as I understand it is related to capistrano. I had to reinstall plugin irs_process_scripts

script/plugin install git://github.com/rails/irs_process_scripts.git

Beware of .svn folder if you're using subversion. Before reinstalling the plugin, I had to remove manually the source plugin, then the files stored in script/process.

rm script/process -rf
rm vendor/plugins/irs_process_scripts/ -rf