I work in a team of engineers that develops a gem with native executables. For contractual reasons, it's important that when we deploy to a new environment, all dependencies use the same exact versions that we tested with. The Gemfile
can only maintain first-order dependency versions, not recursive ones. For this reason, we've historically kept our lockfile checked into github, but this has prevented us from upgrading bundler ever since the 1.14 release. The problem is that we have development machines that are both OSX and Linux, and starting in 1.14, the beginning of the lockfile in the gem repository changed from:
PATH
remote: .
specs:
engine (21.2.13)
<gemspec dependencies here>
to
PATH
remote: .
specs:
engine (21.2.13-x86_64-linux)
<gemspec dependencies here>
This is a problem because when a developer pulls the repo on OSX and runs bundle install
, it will change the contents of the lockfile. Then, when a linux developer does the same, it'll change all over again, creating a bunch of spurious changes in the git history of the lockfile!
I tried running bundle lock --add-platform x86_64-linux
and bundle lock --add-platform x86_64-darwin
, hoping that this would convince bundler to maintain two entries for the different platforms, instead of flipflopping between them. It did produce duplicate entries for some of the gems in the GEM
section of the lockfile, but not for the one in the PATH\n
specs:
section.
Currently, our Gemfile contains the line:
gemspec name: "engine"
which loads engine.gemspec
. This file contains:
Gem::Specification.new do |spec|
...
spec.platform = Gem::Platform::CURRENT
...
end
which I suspect is the problem. I tried including the gemspec twice in the Gemfile, and using a global variable to specify the platform to use, but bundler only loads it the first time, and skips over the second attempt.
Does anyone know of a solution that will allow us to keep both platform-specific gem versions in the same lockfile?
Or otherwise, is there a way to turn off bundler's new-ish behavior that appends the platform name to the gem version? In the past, when the lockfile simply specified "21.2.13" and our gemserver contained two copies of each version (with binaries built for the two platforms), bundler never had any issues resolving the correct version for the current machine, so this seems like the lockfile storing superfluous information. Can I somehow tell it to stop?