Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting BUNDLE_PATH is not a feature! #297

Closed
kwerle opened this issue Oct 22, 2019 · 7 comments
Closed

Setting BUNDLE_PATH is not a feature! #297

kwerle opened this issue Oct 22, 2019 · 7 comments

Comments

@kwerle
Copy link

kwerle commented Oct 22, 2019

➜  ~ docker run --rm ruby:2.5.7 bash -c 'echo $BUNDLE_PATH'
/usr/local/bundle

Having the environment variable BUNDLE_PATH being set is a surprise. I didn't set it, and bundler uses the environment variable over the file configuration. Bundler has a default if it's not set.

I don't think the ruby container should set this environment variable.

@wglambert
Copy link

Looks like it was an upstream recommendation

ENV BUNDLE_PATH="$GEM_HOME" \
BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
# path recommendation: https://github.com/bundler/bundler/pull/6469#issuecomment-383235438

#208

@kwerle
Copy link
Author

kwerle commented Oct 22, 2019

I don't see a call for it, and it really is painful. I don't expect anyone but me to set environment variables unless they are specifically required by the software in a container - and it just isn't.
In addition, there is no good way to unset an environment variable in a child container. You pretty much need to resort to

RUN unset BUNDLE_PATH

which I would describe as a workaround. Everyone who sets BUNDLE_PATH in their .bundle/config file is going to see it break with this change.

@kwerle
Copy link
Author

kwerle commented Oct 22, 2019

And even RUN unset BUNDLE_PATH is not sufficient. This really is a breaking change.

@yosifkit
Copy link
Member

The BUNDLE_PATH was added in #69. At this point, I don't think we could roll that back without breaking users. Can't you work around in by setting the value to be empty?

$ docker run -it --rm -e BUNDLE_PATH= ruby env
PATH=/usr/local/bundle/bin:/usr/local/bundle/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=37ca18bf911d
TERM=xterm
BUNDLE_PATH=
RUBY_MAJOR=2.6
RUBY_VERSION=2.6.5
RUBY_DOWNLOAD_SHA256=d5d6da717fd48524596f9b78ac5a2eeb9691753da5c06923a6c31190abe01a62
GEM_HOME=/usr/local/bundle
BUNDLE_SILENCE_ROOT_WARNING=1
BUNDLE_APP_CONFIG=/usr/local/bundle
HOME=/root

@kwerle
Copy link
Author

kwerle commented Oct 22, 2019

I have just realized that the real root of the poison is

BUNDLE_APP_CONFIG=/usr/local/bundle

What that is saying is that your app is located in /usr/local/bundle instead of '.'.
That is why changes to ./.bundle/config are failing.

It looks like that was done at the same time. Fortunately, I can set that correctly for my app and that should do the trick. But it seems like it was a horrible idea!

@yosifkit
Copy link
Member

That was done to facilitate a user that mounts their working directory into a ruby container so that they can live edit and not have to rebuild their image. This would either mask the installs done in the image via bundle install or very often the local directory already had a .bundle directory that contains stuff for their host (like darwin) that would be incompatible with the container.

@kwerle
Copy link
Author

kwerle commented Oct 23, 2019

Ugh. I don't like it, but I can work around it. It would have been much nicer to do all the default config settings in ~/.bundle/config and leave environment variables out of it. Much easier to tweak files than env vars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants