-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Upgrading to Bundler 1.16 causes bundler to look for Gemfile in root directory #6154
Comments
I wonder if the behavior I'm seeing is related. So in 1.15, the following worked:
but it fails to require This commit looked like a likely offender, but I only poked around for a few minutes: 4337a49#diff-22d99f042aaf58eb9bf0886d01594802 It was surprising to me that a cc @supertopher |
Hi, what's the value of |
I wonder if #6201 has fixed this |
Has Bundler v1.16.1 fixed this? |
@segiddins, #6201 has only fixed it partially. We put Gemfile and Gemfile.lock in container root when installing gems during build. This leads to all the binstubs pointing to that Gemfile. Since we use a |
I don't understand what the problem is there? Are you not using the gemfile you're installing? |
We encounter this problem last week while upgrading our app to Ruby 2.4/Bundler 1.16 using the docker official images, and I think the following can expand on which scenarios this is happening: The Docker image has a predefined The first We added a I think it would be interesting if the bundler binstub could be more portable regarding where the Gemfile it looks for is, but I also feels that the docker image is more opinionated than users would expect, so I'm not sure on how we can make a broader fix for this. I hope this helps to shed a light on the issue. |
Our team is using official ruby docker image. And we ran into this problem one month ago. We couldn't figure out what is the reason. But we did find one workaround. Either run I also wrote a problem demo script: #!/usr/bin/env bash
function colorize_echo() { echo -e "\033[0;${1}m${@:2}\033[0m"; }
function red_echo() { colorize_echo 31 $@; }
function green_echo() { colorize_echo 32 $@; }
function yellow_echo() { colorize_echo 33 $@; }
function blue_echo() { colorize_echo 34 $@; }
CURRENT_DIR="$(pwd)"
DIR_NAME=docker-ruby-bundle-test
IMAGE_NAME=$DIR_NAME:latest
blue_echo "Create test dir"
mkdir -p $DIR_NAME
cd $DIR_NAME
blue_echo "Create dockerfile"
cat <<END > Dockerfile
FROM ruby:2.3
ADD Gemfile /tmp/bundle/
RUN cd /tmp/bundle && bundle install
END
blue_echo "Create gemfile"
cat <<END > Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "json", "2.0.3"
END
blue_echo "Build docker image"
docker build --tag $IMAGE_NAME .
blue_echo "Problem demo A"
docker run --rm $IMAGE_NAME bash -c '
echo hostname:
hostname
echo pwd:
pwd
echo ls:
echo `ls`
echo bundle:
bundle'
red_echo "What? How pwd:/ can run bundle? Where is the Gemfile?"
blue_echo "Problem demo B"
docker run --rm $IMAGE_NAME bash -c '
echo hostname:
hostname
echo pwd:
pwd
echo ls:
echo `ls`
cat <<END > Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "json", "2.0.4"
END
bundle'
red_echo "What? Why still use the json 2.0.3?"
blue_echo "Problem demo C"
docker run --rm $IMAGE_NAME bash -c '
cd /tmp/bundle
echo hostname:
hostname
echo pwd:
pwd
echo ls:
echo `ls`
cat <<END > Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "json", "2.0.4"
END
bundle'
green_echo "OK... Now it works."
blue_echo "Cleanup"
docker rmi $IMAGE_NAME
cd "$CURRENT_DIR"
rm -rf $DIR_NAME It looks like there is a cache problem. You can see even if I create a new Dockerfile in the running container. The bundler won't use it. It will keep using the previous one. And no matter I |
Thanks @lucasmazza for the |
Nice! Thanks @deivid-rodriguez the |
No problem, happy that it works! :) |
@deivid-rodriguez
If I remove BTW, if I just run |
Too bad... :( Back to square one, then... |
We've created a repository reproducing this issue via Docker, if anybody has any ideas of how to fix this (for now, we've pinned to an old version of bundler). Branch Branch Thank you! Rachel & @heycait |
Can you reproduce this without Docker? |
@segiddins Nope, in our repo we created a non-Docker version that works: https://github.com/rheaton/bundler_issue_6154/blob/master/install.sh Edit: I tried it out on OSX and couldn't reproduce, so it could be a Linux-specific problem or a Docker-specific problem. Not sure which. :-/ |
We're seeing this problem on our docker alpine images as well. We tried What did work was disabling spring! 😅 we sticked a I'd also be happy to provide more information about my env if needed! |
I was able to build off of @rheaton work and reproduce this issue without using Docker: https://gist.github.com/eanlain/83f97f919701c864fb68dfdcf813cf5a I also made an attempt at fixing the issue in #6469. |
Same Problem for us. We build a "prebuild" image using the official ruby base images with our Gemfiles as a kind of cache, so we don't have to install every gem from rubygems for every job.
This prebuild image is then used in CI to speed up test/spec/lint/etc execution with gitlab-ci. Gitlab-CI will clone the Repository into /builds/group/project and uses this directory as working directory. Gitlab-CI will in the end execute our script
All our jobs are now failing, cause the Gemfile ( IMHO: |
Interesting so I just ran into this same issue using the ruby:2.5 docker image, however if I used a BUNDLE_PATH other than /user/local/bundle the generated bin stub was totally different and looked like this:
But as soon as the path was /usr/local/bundle the generated stub was as per Gregs example above (generated by bundler and with a werid ../../ path). Anyway I realized I had an old image using Bundler 1.16.1 so I trashed that and fetched a fresh image which has Bundler 1.16.2 and the issue has gone away, no matter what my BUNDLE_PATH is the generated stub is as per my pasted version above and everything works as expected. |
OK I get it now it was https://github.com/docker-library/ruby/pull/209/files that removed BUNDLE_BIN that fixed it! |
This issue seems to have been fixed. Closing. |
Summary
@jenspinney and @deniseyu discovered this issue when using bundler in a docker image we build containing bundler 1.16: https://github.com/cloudfoundry/capi-dockerfiles/blob/26ac90206a234ad29b2775500d471a267d8fced4/capi-ruby-units/Dockerfile#L4
The error looks like this:
Our workaround is to explicitly sets
BUNDLE_GEMFILE
to point to the correct Gemfile.Details
After upgrading from Bundler 1.15 to 1.16,
bundler config
is reporting that theBUNDLE_GEMFILE
env var is set to/Gemfile
, despite no such environment variable exisiting.Looking in
/usr/local/bundle
, we see a bunch of files in the/usr/local/bundle/bin
directory that all follow this pattern:That
../../../../../Gemfile
filepath looks pretty suspicious, and we don't know why Bundler is generating it.The text was updated successfully, but these errors were encountered: