views:

443

answers:

2

I have an older Rails app that I need to run. But I have the latest version of Rails.

When I try to run this older app it says:

Missing the Rails 1.99.0 gem. Please gem install -v=1.99.0 rails

But when I run the command: gem install -v=1.99.0 rails

ERROR: could not find gem rails locally or in a repository

Not sure what to do next. Could someone help me understand what's happening here?

And my second question, related to this problem is: It seems silly that I need to revert to an older version of Rails just to run this one legacy app - there must be a better way of doing this?

+3  A: 

AFAIK, v1.99.0 is sort of a v2.0 prerelease, so you could try installing v2.0.x, changing the RAILS_GEM_VERSION in config/environment.rb and runing rake rails:update.

If you think about it, it's not as silly as it might seem at first. You make an app using a fast evolving web framework as RoR. Your choices are: continue developing your app at aproximately the same pace the framework is evolving, or freeze the rails gem (and evertything else your app depends on, like gems, plugins) into your app in order to make it less fragile to expecting gem updates.

xyz
Oh, what I meant about 'silly' is: I need to install a gem to run this app and then I need to uninstall it and install a different rails gem for some other app. That seems silly to me. Is there any way to install a rails gem for each of the rails versions I need to run and then run whatever I need each time? Or do I need to install and uninstall repeatedly?
Bijou
You can have multiple installs of Rails on a system at once - that's what RubyGems is designed for. Your particular problem here is that 1.99.0 wasn't a "real" release and thus is no longer available on the gem servers.
Sarah Mei
That worked! Thanks, guys. So rails knows I need version 2.0.1 because that's what I put in the environment.rb file? So when I run script/server I don't need to pass any explicit parameters. And I can still run my newer Rails apps without uninstalling anything because environment.rb will indicate to use the newer version of Rails for those. I hope I've understood this correctly.
Bijou
I would use 2.0.3 (I think) it had some security patches in it but will most likely support your app.
railsninja
+2  A: 

Regarding the second question: yes it is silly. Fortunately the Rails team spotted that silliness and at some point they gave us the ability to "freeze" the versions of Rails libraries required by an application (and also specific gem versions) into the vendor directory.

To freeze your version of Rails:

rake rails:freeze:gems

There's a good blog post from a while back describing this.

Mike Woodhouse