Is there any difference between specifying exact versions of third-party libraries in Gemfile
and using Gemfile.lock
?
If I use exact versions in Gemfile
will it be the same as distributing Gemfile.lock
?
No, an exactly specified Gemfile
and using a Gemfile.lock
is not the same.
Your Gemfile
might include all gems you are using with a specific version. But the Gemfile.lock
will also include all gems that are dependencies of the gem you use. That means that a typical Gemfile.lock
will include way more gems when a Gemfile
.
Furthermore: You might have gems or gem versions to your Gemfile
that are incompatible with each other. A Gemfile.lock
is generated by bundler and represents a set of gem versions that are compatible with each other. If bundler is not able to fulfill all required dependencies then it will not generate a Gemfile.lock
.
That said: Pin only versions in your Gemfile
that you need to pin because of version requirements of your app. Let bundler find a valid combination and check that Gemfile.lock
into version control system.