Should I add the version for each gem in my Gemfile? Is it a best practice? Just recommended?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With