Do You Check in Your Rvmrc File

Do you check in your rvmrc file?

Source Control Management is mainly about reproducibility: are you able to reproduce a version of a development effort based on what you have stored in your SCM?

If that .rvmrc file is needed for any developer on your project to be able to work (with the right artifacts), then yes, you should versioned it.

As mentioned in RVM Best Practices:

No. 2 - Check your rvmrc into source control.

By checking the aforementioned rvmrc into source control along side your app, you're ensuring all users have a consistent environment when they're using rvm.

By also automating gemset installs and the like (e.g. check out the rvmrc in the rvm-site repository or the TEDxPerth repostory's rvmrc) you also make getting started as simple as changing directory.

On top of this, you can also automatically make your deployments setup your application specific environment.

Other developers can turn of use of gemsets on their RVM with:

echo rvm_ignore_gemsets_flag=1 >> ~/.rvmrc

This will make them use default gemset always.

Should I check in `.ruby-gemset` and/or `.ruby-version`?

For standard projects

Check in .ruby-version if your project depends on a ruby like ruby-2.0.0.
Check in .ruby-gemset only if your team agreed on it.
Add .rvmrc to .gitignore so anyone can override .ruby-* files settings with .rvmrc.

For gems

Check in .ruby-version with ruby-1.8.7 only if your project still targets ruby 1.8.7, otherwise check it in only if your gem requires it.
Do not check in .ruby-gemset.

Is it a Bad Practice to Have Both a .rvmrc and a .ruby-version in a Ruby Project?

It is a "bad practice" in that it maintains two conventions at once, which can lead to version management issues in some environments. It also makes it possible for one of the conventions to fall out of sync with the other in regards to the version of ruby used in the project. The .ruby-version file is more conventional at this time, so it would be best to remove the .rvmrc file and only maintain .ruby-version.

How to get rid of RVM notice

According to the documentation:

To turn off the project specific rvmrc functionality in your $HOME/.rvmrc set:
rvm_project_rvmrc=0

I don't have a RVM instance to try it out, but I guess that's what you are looking for.

I'd also suggest to use rbenv instead of RVM, for the following reasons.

Use rvmrc or ruby-version file to set a project gemset with RVM?

If your .rvmrc file contains custom shell code, continue using .rvmrc as it allows you to include any shell code.

If your only aim is to switch Ruby versions, then use .ruby-version which is supported by other Ruby version switchers such as rbenv or chruby. This file also does not require trusting as it is just the name of a Ruby version and will not be executed in any way.

If you use .ruby-version you can include @gemset in the file but this will not be compatible with other switchers. To maintain compatibility use the gemset name in a separate file .ruby-gemset which is ignored by other tools (it works only together with .ruby-version).

For example, if you have a simple .rvmrc:

rvm use 1.9.3@my-app

It can be transformed to .ruby-version:

1.9.3

And .ruby-gemset:

my-app

Be sure to remove the .rvmrc file as it takes precedence over any other project configuration files:

rm .rvmrc

How to make rvmrc file in project root folder?

It seems that there is a small mistake. Inside your .rvmrc file add:

rvm use ruby-1.8.7-p352@gemset --create

Also you might want to change the name of your gemset to something that is a bit more intuitive to read :)

UPDATE

Using the rvmrc file has now been deemed deprecated. Instead a .ruby-version file with the ruby version e.g. '2.0.0' and a .ruby-gemset file with the gemset name e.g. 'monkeys_of_doom'

This way developers using other version managers such as rbenv can pick up the ruby version in an automated fashion.

How to make rvmrc file in project root folder?

It seems that there is a small mistake. Inside your .rvmrc file add:

rvm use ruby-1.8.7-p352@gemset --create

Also you might want to change the name of your gemset to something that is a bit more intuitive to read :)

UPDATE

Using the rvmrc file has now been deemed deprecated. Instead a .ruby-version file with the ruby version e.g. '2.0.0' and a .ruby-gemset file with the gemset name e.g. 'monkeys_of_doom'

This way developers using other version managers such as rbenv can pick up the ruby version in an automated fashion.



Related Topics



Leave a reply



Submit