Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice, adding a version to each gem in the gemfile?

Should I add the version for each gem in my Gemfile? Is it a best practice? Just recommended?

like image 275
AdamT Avatar asked Jul 06 '12 06:07

AdamT


People also ask

How do I install a specific version of a gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.

How do I update a gem to a specific version bundle?

The correct way to update the version of a gem to a specific version is to specify the version you want in your Gemfile, then run bundle install . As for why your command line was failing, there is no -version option.

Should I Gemfile lock version?

You can (and should) specify versions of gems in your Gemfile but without the Gemfile. lock being included in Git. Then nobody else will get to benefit from your work of checking that the updated Gems still work. You should check your Gemfile for updates frequently and bundle update where appropriate.

How do you install gems you added to your Gemfile?

run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from. Save this answer.


1 Answers

I do prefer to have all my gems locked to a specific version in production. Considering there might be newer versions that break compatibility with other gems or deprecate some APIs, you want to be 100% sure that you won't get surprisingly broken app when you deploy because of gem inconsistencies. Updating gems should only be done locally in development, by updating their Gemfile entries and testing each new version against the rest of you code and libraries.

like image 120
svilenv Avatar answered Oct 13 '22 20:10

svilenv