-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Bundler 1.16 incorrectly captures/stores BUNDLE_GEMFILE
information into binstubs, which breaks in scenarios where multiple Gemfiles have been bundle installed
.
#6162
Comments
Likely related: #6154 |
I'm seeing this too. @jchesterpivotal very thorough investigation and report. 😍 |
This workaround stopped working for us
We had to also add
|
I'm not sure whether this is a bug in In particular, with the In my case, doing |
To be clear: Bundler already creates executables that don't capture a Gemfile as the regular RubyGems executables. Those executables are always created. Bundler binstubs are an optional addition, intended to be application-specific. Capturing the relevant Gemfile is a feature, not a bug. If you don't want to use the captured Gemfile, either stop generating Bundler binstubs or set |
Makes total sense @indirect. So this is a new feature in |
I'm sure "bundler binstubs" are not a new feature per se (maybe the bundler binstub for bundler itself is, though), I'm just trying to figure out why stuff that worked in |
I'd be fine being wrong if it's downstream in the docker image. But it was a surprising change in behaviour. |
The intended change was to support situations like this one:
If the binstub at The change in observed behavior might come down to a failure in imagination on our part... we didn't think that anyone would be generating application-specific binstubs and then trying to use those stubs in other applications. In this case, I feel like it's reasonable to expect users to run the RubyGems binstubs if they want application-independent behavior, and run |
I see, the more I think about it the more this seems like an issue with ruby's official docker image configuration. Ruby's official docker image is setting these in its base ruby image: ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_PATH="$GEM_HOME" \
BUNDLE_BIN="$GEM_HOME/bin" \
BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH $BUNDLE_BIN:$PATH So that means every docker image using ruby as its base image is supposed to host a single application (furthermore, a single Gemfile), otherwise each application's binstubs will be overwriting each other everytime they run |
@deivid-rodriguez yes, I believe that is correct. The config you pasted above looks extremely optimized for a single Ruby application, with a single Gemfile. I think you would likely want to remove some or all of those ENV settings if you have more than one application inside your container. |
Yeah, the thing is |
To be clear, this comes about as a CI consideration. Running We've also encountered similar-but-not-quite-the-same problems with monorepo projects. Bundler assumes you have a monolithic ruby codebase and that it still has a single Gemfile. But we have cases where a subdirectory has a Gemfile (
|
Yeah, I was thinking the same thing...
I think #6201 might be an improvement in this regard? |
I honestly don't feel qualified to say, but ... maybe? It's a pity @RochesterinNYC isn't still here at Pivotal, normally I'd have ambushed him for a closer look. Our better move might be disentangling our Docker images. We've tried once or twice and been thrown back from Fort Fiddly Interactions. I have a longstanding grudge against Dockerfiles as a way of building images, mostly because they tend to encourage these kinds of ball-of-mud situations. |
@jchesterpivotal I think I now understand what you're saying... |
Ugh, accidentally commented too soon. Can you try Bundler built from master, now that #6201 has landed? I am hoping that it will fix that specific issue of |
As it happens I've rotated away from the affected team. One of @mbildner, @xtreme-debbie-chen or @pivotal-ivan-wang might need to carry this forward. |
Duplicate of #6154 |
Issue
Bundler 1.16 incorrectly captures/stores
BUNDLE_GEMFILE
information into binstubs, which breaks in scenarios where multiple Gemfiles have beenbundle installed
.We think we did not observe this sooner because of the time it took for bundler 1.16 to propagate to our CI pipeline: first from Bundler to the standard
ruby:2.4.2
Dockerfile, then from there to our CI-image-building job, and then a delay until a job using our CI image was triggered. But we believe the issue existed from the time that bundler 1.16 was released.Investigation
Yesterday our CI builds began to fail inexplicably:
We investigated the commits leading up to the build, but none of them were related to Bundler, Docker, Rake, any Gemfiles etc.
We noticed that our logs had changed in an interesting way, however:
Seen in broken build:
Seen in working build immediately prior to broken build:
At first we suspected we'd messed up our Gemfile, but it had not changed. We then realised that the "12 Gemfile dependencies" result was from a different Gemfile from the one in the directory.
Our CI / Docker process
How could this happen? Well, to begin with, we run all our builds inside Docker containers using Concourse. As an optimisation, we pre-build images that contain dependencies used by multiple codebases in our system. Then all CI builds use the common image.
bundle exec
is used to keep dependencies straight and previously worked fine.Here is a Dockerfile based on our internal one:
When we
fly intercept
a broken build to poke inside a container usingfirst.gemfile
, we can recreate the failure behaviour. After some more poking around, we realise that the list of installed gems is fromthird.gemfile
, notfirst.gemfile
.It seems as though, during the
docker build
used to create our CI image, Bundler has somehow locked onto the thirdBUNDLE_GEMFILE
:A bit weird, but we figure easily fixed. But it is not fixed by
bundle config --delete
:We check all the
.bundle/config
places the docs tell us to look, but none of them refer toBUNDLE_GEMFILE
orthird.gemfile
.So where is the configuration coming from?
Proximate cause of issue
After using
grep
over the whole FS, we find it being hard-coded into binstubs:So that unless we set
BUNDLE_GEMFILE
every time we run bundler, it will not work forfirst.gemfile
andsecond.gemfile
cases.This is a regression vs 1.15.4, where it worked as expected.
Workaround
Our workaround is to add this to our Dockerfile:
The text was updated successfully, but these errors were encountered: