Question

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?

Was it helpful?

Solution

You need to tell RVM which gemset to use. Try this:

rvm gemset use project_2

If that works, then you may wish to create a .rvmrc file in project_2's root directory so that it automatically switches to that gemset when you enter the directory:

cd /path/to/project_2
rvm --rvmrc --create 1.9.3@project_2

That'll create a .rvmrc in /path/to/project_2. cd out of the directory and back in, and it'll prompt you asking if you trust the .rvmrc file. By default, it'll only ask you the first time.

Edit:

It is important to note that when creating a new .rvmrc, you need to cd out of the project directory in all open terminal sessions (including rails s and rails console). Otherwise the app will continue using the gemset from project_1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top