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.

4 Answers 4

96

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.

3
  • And what if you already created the gemset? Will you be forced to add .ruby-version and .ruby-gemset manually at that point?
    – Donato
    Commented Apr 2, 2015 at 2: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
    Commented Oct 16, 2015 at 16:35
  • 5
    rvm --create --ruby-version use ruby-x.x.x@project
    – Asarluhi
    Commented Feb 27, 2016 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.

1
  • 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
    Commented Dec 11, 2014 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.

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.