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

浪子不回头ぞ 提交于 2019-11-30 04:41:31

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.

Checking in .rvmrc, .ruby-version or .ruby-gemset?

FOR:

  • Your project has different branches (say a RubyGems project supporting Ruby 1.8, 1.9 and 2.0 versions). Its better to check in this file, so that your developers don't have to keep on editing these files when they switch branches. The same doesn't apply for an application though, where you'll mostly be working on only one Ruby version.

  • Same case as above, but say you are running a CI server (say TeamCity/Jenkins/...) which automatically just runs rake spec for every check-in. You don't want to create separate build pipelines for each branch, just for the sake of having a separate rvm use ... for each branch. You just want the Ruby version selected automatically depending on the branch

  • You have tight control over the environment and all the developers. You either don't need or dictate that they use the same ruby and gemset

  • You are using Phusion Passenger or Capistrano, which automatically read .rvmrc files and chooses the right ruby for deployment/hosting

Also refer RVM Best Practices

AGAINST:

  • You can compile your own Ruby in RVM, with some experimental patches, and give it a custom name.

    e.g. rvm install 1.9.3 --patch railsexpress,falcon --name ruby-1.9.3-perf

    In the above example, I've installed Ruby 1.9.3 with some great speed up patches (btw they are awesome), but rather than calling it 1.9.3, I'm calling it my own name. I would say rvm use ruby-1.9.3-perf whenever I need this. In this case, if the project has its own .ruby-version, then it messes up my environment. In my project, these patches are standard and we actively recommend those. But how developers name the resultant compiled Ruby is up to them

  • Similarly, people use different gemsets. Some don't use gemsets at all. Some share the same gemset with different (but similar) ruby projects. Given this, again a single .ruby-gemset also doesn't work for everybody

  • Your project has an obscure ruby version which just says 1.9.3. Your developers first installed the latest Ruby 1.9.3-p329. But they later just update RVM/Rbenv (since they're working on other projects). Their .rvmrc or .ruby-version just breaks, since the latest version of Ruby registered in RVM/Rbenv just changed from ruby-1.9.3-p329 to .ruby-1.9.3-p362, and it will say ruby-1.9.3-p362 not installed. This scenario tends to happen often.

As long as you specify a proper full name for your Ruby version (including patch level), you should be OK. Let's say your project's .ruby-version says ruby-1.9.3-p329. Its easy to compile your own Ruby with all these patches, and still just custom name it ruby-1.9.3-329 just so that the config files will pick up this ruby instead of the standard ruby.

I would include .ruby-version - you and anyone else working on the project, along with your servers, should be using the same version of Ruby.

.ruby-gemset.... up to you, I think.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!