RVM and Frozen Rails Conflict

I have an existing rails application and want to switch to using RVM in order to tie particular versions of Ruby, Rails and RubyGems to this application. My existing Rails application has a frozen Rails version 2.2.2 tied into it and so exists in my vendor/rails directory.

Before I installed RVM, the following question came into my mind:
How do you take an existing Rails app and determine which gems and versions it uses?
I don’t know the answer yet but do have one solution as described below.

I’d like to use the Bundler gem but really need to know which gems to specify in the Gemfile, which sits in the root of my rails application directory. So, my goal here is to use RVM to reconstruct the list of gems by adding one gem at a time into my application and troubleshoot. Eventually, I’ll come up with a list of gems my app requires and assuming I’m successful, I can use that list to construct the Gemfile for Bundler.

Initially when you install RVM, you start with a clean slate, meaning your gem list won’t show any installed gems for a particular ruby version you’ve installed into your .rvm directory via the rvm command. Prior to RVM you would have all of these gems installed but it was very difficult to know which gems exactly you used in your app. I’m hoping that I can not only tie a set of gems to a particular ruby version but I’d like to associate a particular ruby, rails and gem version to each particular application. I hope RVM will support this. Still playing around with it to find out. Feel free to comment below. Thanks!

  1. Install RVM from GitHub Repository as indicated here http://rvm.beginrescueend.com/rvm/install/
  2. rvm install 1.9.1; rvm 1.9.1 –default (–default makes it so 1.9.1 will be your default version, in other new shells you open up as well)
  3. remember if you want to switch back to your system Ruby, Rails and RubyGems, just type: rvm system. To switch to 1.9.1, for example, again, just type rvm use 1.9.1
  4. gem install rails (notice when you are installing gems under rvm, you should NOT type ‘sudo’)
navid@~/Development/yourapp: script/server
/Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require': no such file to load -- test/unit/error (MissingSourceFile)
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `block in require'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/deprecation.rb:224:in `<top (required)>'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `block in require'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support.rb:37:in `<top (required)>'
	from /Users/navid/Development/yourapp/vendor/rails/railties/lib/commands/server.rb:1:in `require'
	from /Users/navid/Development/yourapp/vendor/rails/railties/lib/commands/server.rb:1:in `<top (required)>'
	from script/server:3:in `require'
	from script/server:3:in `<main>'

Solution: remove the frozen rails version from your application while in your system settings (i.e. while in your non RVM settings).

So, I did steps 1 through 4 above and then typed script/server in my rails application’s root directory and noticed conflicts because I had frozen rails 2.2.2 into my application earlier.

So, the solution is to unfreeze rails from the application which basically deletes the /vendor/rails directory.

With RVM, I also am hoping that freezing the rails versions into an application is no longer needed and actually should not be done, or else you’ll run into this conflict.

However, keep in mind, you’ll probably run into a similar issue if you try to unfreeze rails while in you RVM environment, if RVM is conflicting with the frozen rails.

So the best thing to do is the following, revert back to your system settings, unfreeze rails and then come back to your rvm environment:

  1. rvm system
  2. rake rails:unfreeze
  3. rvm use default or rvm use 1.9.1
VN:F [1.9.22_1171]
Rating: 1.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
RVM and Frozen Rails Conflict, 1.0 out of 5 based on 1 rating
Facebook Twitter Email

Leave a Reply