Create .ruby-version and .ruby-gemset with rvm

Ruby on-RailsRubyRvmGemset

Ruby on-Rails Problem Overview


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.

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

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.

Solution 2 - Ruby on-Rails

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.

Solution 3 - Ruby on-Rails

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.

Solution 4 - Ruby on-Rails

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)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTyler DeWittView Question on Stackoverflow
Solution 1 - Ruby on-Railscappie013View Answer on Stackoverflow
Solution 2 - Ruby on-RailsBob RobertsView Answer on Stackoverflow
Solution 3 - Ruby on-RailsJaskirat SinghView Answer on Stackoverflow
Solution 4 - Ruby on-Railstobybot11View Answer on Stackoverflow