33

I'm trying to make a gemset the default whenever I start a new terminal in Mac OS X:

rvm use 1.9.3@rails3.2 --create --default

That seems to work, the rails3.2 gemset becomes the current gemset:

$ rvm gemset list

gemsets for ruby-1.9.3-p0 (found in /Users/me/.rvm/gems/ruby-1.9.3-p0)
   global
=> rails3.2

$

But when I open up a new terminal, the rails3.2 gemset is no longer the current:

$ rvm gemset list

gemsets for ruby-1.9.3-p0 (found in /Users/me/.rvm/gems/ruby-1.9.3-p0)
   global
   rails3.2

$

What do I do?

at.
  • 50,922
  • 104
  • 292
  • 461

6 Answers6

51

Have you tried specifying rvm --default use after the gemset is created so passing:

 rvm --default use ruby-1.9.3-p0@rails3.2

and then seeing if that sticks? Using create and default at the same time isn't something I've tried before, it's the only thing that strikes me as out of place.

Given the discussion below I'd offer this as a means for dealing with the problem. (Personally, I'd probably implode rvm and start over.) But, if you wanted to try to make a go of it with this install then I'd look at your .rvm folder, specifically in .rvm/environments/default which will contain all the environment variables exported for the default environment. Here you'll find rvm_gemset_name this may be set incorrectly and isn't updated for some reason (permissions?) or is set correctly in which case its some other environment issue. You could try manually setting it here in the file if its not correct.

Mike K.
  • 3,751
  • 28
  • 41
  • same problem... I run that and `rvm gemset list` looks good. But then I open up a new Terminal tab and the rails3.2 gemset is no longer the current one. – at. Feb 14 '12 at 18:59
  • BTW, I've used ruby-1.9.3-p0@rails3.2 and also just 1.9.3@rails3.2, they both behave the same – at. Feb 14 '12 at 19:00
  • .rvmrc contains simply an `rvm_path` environment variable and I don't have a .profile – at. Feb 15 '12 at 04:56
  • I've modified my answer with some other things to try. hope this helps. – Mike K. Feb 15 '12 at 05:13
  • in my `~/.rvm/environments/default` file I only have the following line regarding rvm_gemset_name: `unset rvm_gemset_name` – at. Feb 15 '12 at 05:45
  • oh, I just realized `~/.rvm/environments/default` is a symbolic link pointing to `ruby-1.9.3-p0`. I guess it should be pointing to `ruby-1.9.3-p0@rails3.2` (another file, this time with the appropriate `rvm_gemset_name`) – at. Feb 15 '12 at 05:48
  • that's not right, comment that and add something like rvm_gemset_name='rails3.2' ; export rvm_gemset_name – Mike K. Feb 15 '12 at 05:48
  • ah didn't see your 2nd comment. yeah that sounds like the right change. – Mike K. Feb 15 '12 at 05:49
  • deleting the default link and creating a new one to the correct gemset seems to work, though a bit scary... is this really how it's done? why wasn't this set when I used the --default flags? – at. Feb 15 '12 at 08:34
  • strange, I have to use `rvm --default gemset use rails328` to make it work... (`rails328` is my gemset) – nonopolarity Oct 25 '12 at 14:25
  • Struggling with this under rvm 1.25.14. When I change the default gemset using `rvm use 2.1.0@myapp_rails3216`, I can see the `~/.rvm/environments/default` file changing to point to the correct gemset, and `printenv PATH` shows the correct gemset in the path. But when I start a new shell, it always reverts to the base `(default)` gemset and PATH for 2.1.0. It remembers the default Ruby version, just not the default gemset path. It's like it's not looking at the `~/.rvm/environments/default` file when it opens a new terminal window. – Mark Berry Jan 11 '14 at 01:54
  • is something in your profile or home folder causing it to set differently? – Mike K. Jan 11 '14 at 17:07
  • Thanks @MikeK. The profile/environment setup looks quite complex. I thought maybe I had [issue #2543](https://github.com/wayneeseguin/rvm/issues/2543) but after upgrading to RVM 1.2.15, the issue persists. I've submitted a new issue, [#2561](https://github.com/wayneeseguin/rvm/issues/2561). – Mark Berry Jan 23 '14 at 01:12
  • Command "rvm list" shows the default as set, but it doesn't actually "get set" when you open a new terminal. This is with the latest rvm update. My system-condition does not match the issue opened by @MarkBerry. Not sure why rvm doesn't just call "use" for the default that is set when a terminal window is opened. – JosephK Jun 15 '15 at 08:43
  • Perhaps worth noting is that a reboot might be necessary, it depends on how/when the env variales are set. My system was relying on `$GEM_HOME` and $GEM_PATH` when starting a new terminal. So of course, setting `rvm` defaults did not update these. – user2953607 Jan 24 '19 at 18:55
7

You can use this command.

rvm use --default <ruby version>@<gemset name>

or

rvm --default use <ruby version>@<gemset name> or

rvm use <ruby version>@<gemset name> --default 
Amrit Dhungana
  • 4,371
  • 5
  • 31
  • 36
6

Use following command to make a gemset as default.

rvm use <ruby version>@<gemset name> --default

eg.

 rvm use 1.8.7-p370@mygemset --default
Ramiz Raja
  • 5,942
  • 3
  • 27
  • 39
0

You can use this command

$ rvm use rubyversion@gemsetname --create --ruby-version

For example : ruby version = ruby-2.1.2

gemset name = gem320

It would be

$ rvm use ruby-2.1.2@gem320 --create --ruby-version.

Even if you open other tab also, it will preserve the settings.

Jai Chauhan
  • 4,035
  • 3
  • 36
  • 62
rubyemerite
  • 372
  • 2
  • 9
  • I did `rvm use ruby-2.2.3@rails426 --create --ruby-version` but it still didn't preserve the settings when I opened other tab, and I got an error saying `Your Ruby version is 2.2.1, but your Gemfile specified 2.2.3 ` – Vipin Verma Mar 08 '16 at 11:04
0

Interesting that nobody has mentioned rvm alias. Try your version-specific variation of this, works for me:

$ rvm alias create default ruby-2.3.0@rails_4_2_6
# me logs out, fetches another coffee
# me logs in
$ rvm list

rvm rubies

   ruby-2.2.4 [ x86_64 ]
=* ruby-2.3.0 [ x86_64 ]

$ rvm gemset list

gemsets for ruby-2.3.0 (found in /home/aclarke/.rvm/gems/ruby-2.3.0)
   (default)
   global
=> rails_4_2_6
0

rubyracer related issue might as well come with libv8. To get around this issue: Step 1: Run the following command to uninstall any existing installation of libv8:

gem uninstall libv8

Install rubyracer by running the following command:

gem install therubyracer -v 0.12.2

Install libv8 by running the following command:

gem install libv8 -v 3.16.14.15 -- --with-system-v8

Try bundle install now:

bundle install
Sk. Irfan
  • 299
  • 3
  • 15