Reputation: 3045
For what possible reason would rvm switch gemsets when I cd into my rails project directory?
I don't have an .rvmrc file. I set a default gemset (which "sticks" for other directories). Here's what I mean:
[20130109_234306] will@localhost:~
$ rvm gemset list
gemsets for ruby-1.9.3-p362 (found in /Users/will/.rvm/gems/ruby-1.9.3-p362)
(default)
global
=> ruby-1.9.3
[20130109_234313] will@localhost:~
$ cd Projects/rails_project
[20130109_234320] will@localhost:~/Projects/rails_project
$ rvm gemset list
gemsets for ruby-1.9.3-p362 (found in /Users/will/.rvm/gems/ruby-1.9.3-p362)
=> (default)
global
ruby-1.9.3
Upvotes: 2
Views: 2322
Reputation: 1531
have two way at least to achieve this, eg:
echo 2.1.1 > .ruby-version
and echo rails4 > .ruby-gemset
add first line #ruby=2.1.1@rails4
to Gemfile
why
.ruby-gemset
?
.ruby-version
also supports gemsets in the form ofruby@gemset
but this is not compatible with other Ruby Versions Managers. Another file might be used to specify the gemset without breaking compatibility -.ruby-gemset
.
I think above is the best practice .
Upvotes: 0
Reputation: 513
You can disable the project .rvmrc which disables project Gemfile checking as well. To do this, add the following line to /etc/rvmrc
or ~/.rvmrc
. Then you wont have to add a .rvmrc file to any project, as they will be ignored with the Gemfile. This was tested on rvm 1.19.6 (Stable)
.
rvm_project_rvmrc=0
Source: https://rvm.io/workflow/rvmrc
Upvotes: 1
Reputation: 53158
The Gemfile in the rails project directory will tell RVM to switch rubies if the Gemfile specifies a ruby version (something like ruby="1.9.3" or #ruby=1.9.3@gemset).
This is because RVM supports more then just .rvmrc
=> https://rvm.io/workflow/projects/#ruby-versions a full list can be found here: https://github.com/wayneeseguin/rvm/blob/master/scripts/functions/rvmrc#L743-L744
Note that RVM will check the following files before the Gemfile: .rvmrc
.versions.conf
.ruby-version
.rbfu-version
.rbenv-version
. So creating a .rvmrc
file with the line "rvm use [email protected]
" would make RVM ignore the Gemfile.
Upvotes: 5
Reputation: 27553
RVM has a feature called Project .rvmrc. In ~/Projects/rails_project
there is a file called .rvmrc
, which contains instructions for RVM for when you move into that project.
Edit: I missed the line about you not having that file. Sorry.
Upvotes: 1