59

Is there a way to create the associated .ruby-version and .ruby-gemset files when creating a new gemset?

With older versions of rvm, one could do rvm --create --rvmrc 1.8.7@project, but that creates .rvmrc files.

I thought I read somewhere we could use the --ruby-version command line switch, but I have been unsuccessful in doing so.

Tyler DeWitt
  • 23,366
  • 38
  • 119
  • 196

4 Answers4

95

I recently had the same problem. rvm --help led me to:

rvm --create --ruby-version ruby-1.9.3@my-gemset  

It created both .ruby-gemset and .ruby-version.

bigmike7801
  • 3,908
  • 9
  • 49
  • 77
cappie013
  • 2,354
  • 1
  • 22
  • 30
  • And what if you already created the gemset? Will you be forced to add .ruby-version and .ruby-gemset manually at that point? – Donato Apr 02 '15 at 02:15
  • @Donato no, this will simply create the files, and move aside any existing .ruby-version or .ruby-gemset file into .ruby-gemset.Todays.Date.Time. In your project, type `ls -a` to verify the hidden files are there and as you expect. – Danny Oct 16 '15 at 16:35
  • 5
    `rvm --create --ruby-version use ruby-x.x.x@project` – Asarluhi Feb 27 '16 at 17:55
41

According to the official RVM docs you can use this:

echo 1.9.3 > .ruby-version

Or you can use this:

rvm --ruby-version use 1.9.3@my_app

The second form will create both .ruby-version and .ruby-gemset.

bantic
  • 4,886
  • 4
  • 29
  • 34
Bob Roberts
  • 1,013
  • 9
  • 15
  • if you want to only specify a ruby version and do it with `rvm` you would do: `rvm --ruby-version use 1.9.3`. This only creates a `.ruby-version` file. – bantic Dec 11 '14 at 17:00
4

Suppose I am creating gemset for my rails app whose name is tptapp then we can do it in following way.

rvm use 2.2.2@tptapp --create

here tptapp is name of gemset, 2.2.2 is Ruby version.

Mikael Auno
  • 8,990
  • 2
  • 21
  • 16
3

All of the above examples require you to type in your ruby version and gemset name .. which is close to the same keystrokes required to vi .ruby-gemset and vi .ruby-version. Assuming you are in a directory where you've already chosen your ruby version and you are pointing at the desired gemset.. this does the trick.

rvm --ruby-version use $(rvm-prompt)
Community
  • 1
  • 1
tobybot11
  • 38
  • 2
  • 2