I recently created a new Rails project, and I believe I created a gemset for it before generating the app.
But when I encounter an error I get a message like this:
File /.rvm/gems/ruby-1.9.3-p194@project_1/gems/activerecord-3.2.8/lib/active_record/relation/finder_methods.rb
Even though I am in project_2. So in theory that should be ruby-1.9.3-p194@project_2 and not project_1.
What can be causing this and how can I fix it?
Thanks.
P.S. I am using RVM.
Edit 1:
I ran rvm gemset list and this is the output:
project_2$ rvm gemset list
gemsets for ruby-1.9.3-p194 (found in /Users/marcamillion/.rvm/gems/ruby-1.9.3-p194)
project_1
=> project_2
project_3
Edit 2:
I just ran gem install rails in my project_2 directory after I created the .rvmrc file for that project after verifying that it is indeed using the gemset for that project specifically. However, when I generate the error again, I am still seeing a reference to the gemset in project_1.
Edit 3:
The output for rvm current:
$ rvm current
ruby-1.9.3-p194@project_2
Edit 4:
Although, when I run rvm current in the same terminal window as my rails s I see:
$ rvm current
ruby-1.9.3-p194@project_1
So how do I set the gemset across all terminal windows for right now, and in the future?
You need to tell RVM which gemset to use. Try this:
If that works, then you may wish to create a
.rvmrcfile in project_2’s root directory so that it automatically switches to that gemset when you enter the directory:That’ll create a
.rvmrcin/path/to/project_2.cdout of the directory and back in, and it’ll prompt you asking if you trust the.rvmrcfile. By default, it’ll only ask you the first time.Edit:
It is important to note that when creating a new
.rvmrc, you need tocdout of the project directory in all open terminal sessions (includingrails sandrails console). Otherwise the app will continue using the gemset fromproject_1.