Skip to content

Commit

Permalink
Stop exposing BUNDLER_VERSION and RUBYGEMS_VERSION environment va…
Browse files Browse the repository at this point in the history
…riables into containers

It is a convenient but not required feature and it was causing the following cryptic error in the binstub generated by Bundler itself (but not in the binstub generated by Rubygems) when `BUNDLER_VERSION` was an empty string:
```
/usr/local/lib/ruby/site_ruby/3.0.0/rubygems/requirement.rb:106:in `parse': Illformed requirement [""] (Gem::Requirement::BadRequirementError)
	from /usr/local/lib/ruby/site_ruby/3.0.0/rubygems/requirement.rb:138:in `block in initialize'
	from /usr/local/lib/ruby/site_ruby/3.0.0/rubygems/requirement.rb:138:in `map!'
	from /usr/local/lib/ruby/site_ruby/3.0.0/rubygems/requirement.rb:138:in `initialize'
	from /bundle/bin/bundle:92:in `new'
	from /bundle/bin/bundle:92:in `activate_bundler'
	from /bundle/bin/bundle:81:in `load_bundler!'
	from /bundle/bin/bundle:105:in `<top (required)>'
	from /bundle/bin/whenever:17:in `load'
	from /bundle/bin/whenever:17:in `<main>'
```
  • Loading branch information
michaelbaudino committed Jul 17, 2023
1 parent 1d9987a commit 2ab02ee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ ARG RUBYGEMS_VERSION_ARG="" \
BUNDLER_VERSION_ARG=""

# Define dependencies base versions
ENV RUBYGEMS_VERSION=${RUBYGEMS_VERSION_ARG:-${RUBYGEMS_VERSION}} \
BUNDLER_VERSION=${BUNDLER_VERSION_ARG} \
NODE_VERSION="16" \
ENV NODE_VERSION="16" \
GOSU_VERSION="1.16"

# Define some default variables
Expand Down Expand Up @@ -164,8 +162,8 @@ RUN set -eux; \

# Install GEM dependencies
# Note: we still need Bundler 1.x because Bundler auto-switches to it when it encounters a Gemfile.lock with BUNDLED WITH 1.x
RUN gem update --system ${RUBYGEMS_VERSION} \
&& gem install bundler${BUNDLER_VERSION:+:${BUNDLER_VERSION}} \
RUN gem update --system ${RUBYGEMS_VERSION_ARG} \
&& gem install bundler${BUNDLER_VERSION_ARG:+:${BUNDLER_VERSION_ARG}} \
&& gem install bundler:1.17.3

# Add dot files to the home directory skeleton (they persist IRB/Pry/Rails console history, configure Yarn, etc…)
Expand Down
2 changes: 1 addition & 1 deletion RECIPES.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ This can be particularly useful with configurations like the one traditionally s
### Bundler 1.x
Our image uses Bundler 2.x by default, but for convenience, it also embeds Bundler 1.x. To use it in your legacy project, simply set the `BUNDLER_VERSION` environment variable from your `docker-compose.yml`:
Our image uses Bundler 2.x by default, but for convenience, it also embeds Bundler 1.x. To use it in your legacy project, simply set the [(undocumented) `BUNDLER_VERSION` environment variable](https://github.com/rubygems/rubygems/issues/3978) from your `docker-compose.yml`:
```yaml
services:
Expand Down
4 changes: 2 additions & 2 deletions test/cowsay/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
ruby_cowsay (0.1.2)
ruby_cowsay (0.1.3)

PLATFORMS
ruby
Expand All @@ -10,4 +10,4 @@ DEPENDENCIES
ruby_cowsay

BUNDLED WITH
1.16.6
2.4.17

0 comments on commit 2ab02ee

Please sign in to comment.