Skip to content

Commit 7df74ad

Browse files
Add paths scoped to ruby version to PATH and GEM_PATH
Newer bundler versions install gems to `$GEM_HOME/ruby/<ruby_version>`, instead of directly to `$GEM_HOME`. So we need to add the proper paths to `GEM_PATH` and `PATH` so that gems and their executables are properly found.
1 parent 8f3650c commit 7df74ad

File tree

25 files changed

+50
-25
lines changed

25 files changed

+50
-25
lines changed

2.4/alpine3.10/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,11 @@ RUN set -eux; \
124124
# install things globally, for great justice
125125
# and don't create ".bundle" in all our apps
126126
ENV GEM_HOME /usr/local/bundle
127+
ENV GEM_PATH $GEM_HOME/ruby/$RUBY_MAJOR.0:$GEM_PATH
127128
ENV BUNDLE_PATH="$GEM_HOME" \
128129
BUNDLE_SILENCE_ROOT_WARNING=1 \
129130
BUNDLE_APP_CONFIG="$GEM_HOME"
130-
ENV PATH $GEM_HOME/bin:$PATH
131+
ENV PATH $GEM_HOME/bin:$GEM_HOME/ruby/$RUBY_MAJOR.0/bin:$PATH
131132
# adjust permissions of a few directories for running "gem install" as an arbitrary user
132133
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
133134
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)

2.4/alpine3.11/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,11 @@ RUN set -eux; \
124124
# install things globally, for great justice
125125
# and don't create ".bundle" in all our apps
126126
ENV GEM_HOME /usr/local/bundle
127+
ENV GEM_PATH $GEM_HOME/ruby/$RUBY_MAJOR.0:$GEM_PATH
127128
ENV BUNDLE_PATH="$GEM_HOME" \
128129
BUNDLE_SILENCE_ROOT_WARNING=1 \
129130
BUNDLE_APP_CONFIG="$GEM_HOME"
130-
ENV PATH $GEM_HOME/bin:$PATH
131+
ENV PATH $GEM_HOME/bin:$GEM_HOME/ruby/$RUBY_MAJOR.0/bin:$PATH
131132
# adjust permissions of a few directories for running "gem install" as an arbitrary user
132133
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
133134
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)

2.4/buster/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ RUN set -eux; \
8383
# install things globally, for great justice
8484
# and don't create ".bundle" in all our apps
8585
ENV GEM_HOME /usr/local/bundle
86+
ENV GEM_PATH $GEM_HOME/ruby/$RUBY_MAJOR.0:$GEM_PATH
8687
ENV BUNDLE_PATH="$GEM_HOME" \
8788
BUNDLE_SILENCE_ROOT_WARNING=1 \
8889
BUNDLE_APP_CONFIG="$GEM_HOME"
89-
ENV PATH $GEM_HOME/bin:$PATH
90+
ENV PATH $GEM_HOME/bin:$GEM_HOME/ruby/$RUBY_MAJOR.0/bin:$PATH
9091
# adjust permissions of a few directories for running "gem install" as an arbitrary user
9192
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
9293
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)

2.4/buster/slim/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ RUN set -eux; \
109109
# install things globally, for great justice
110110
# and don't create ".bundle" in all our apps
111111
ENV GEM_HOME /usr/local/bundle
112+
ENV GEM_PATH $GEM_HOME/ruby/$RUBY_MAJOR.0:$GEM_PATH
112113
ENV BUNDLE_PATH="$GEM_HOME" \
113114
BUNDLE_SILENCE_ROOT_WARNING=1 \
114115
BUNDLE_APP_CONFIG="$GEM_HOME"
115-
ENV PATH $GEM_HOME/bin:$PATH
116+
ENV PATH $GEM_HOME/bin:$GEM_HOME/ruby/$RUBY_MAJOR.0/bin:$PATH
116117
# adjust permissions of a few directories for running "gem install" as an arbitrary user
117118
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
118119
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)

2.4/stretch/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ RUN set -eux; \
8383
# install things globally, for great justice
8484
# and don't create ".bundle" in all our apps
8585
ENV GEM_HOME /usr/local/bundle
86+
ENV GEM_PATH $GEM_HOME/ruby/$RUBY_MAJOR.0:$GEM_PATH
8687
ENV BUNDLE_PATH="$GEM_HOME" \
8788
BUNDLE_SILENCE_ROOT_WARNING=1 \
8889
BUNDLE_APP_CONFIG="$GEM_HOME"
89-
ENV PATH $GEM_HOME/bin:$PATH
90+
ENV PATH $GEM_HOME/bin:$GEM_HOME/ruby/$RUBY_MAJOR.0/bin:$PATH
9091
# adjust permissions of a few directories for running "gem install" as an arbitrary user
9192
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
9293
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)

2.4/stretch/slim/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ RUN set -eux; \
108108
# install things globally, for great justice
109109
# and don't create ".bundle" in all our apps
110110
ENV GEM_HOME /usr/local/bundle
111+
ENV GEM_PATH $GEM_HOME/ruby/$RUBY_MAJOR.0:$GEM_PATH
111112
ENV BUNDLE_PATH="$GEM_HOME" \
112113
BUNDLE_SILENCE_ROOT_WARNING=1 \
113114
BUNDLE_APP_CONFIG="$GEM_HOME"
114-
ENV PATH $GEM_HOME/bin:$PATH
115+
ENV PATH $GEM_HOME/bin:$GEM_HOME/ruby/$RUBY_MAJOR.0/bin:$PATH
115116
# adjust permissions of a few directories for running "gem install" as an arbitrary user
116117
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
117118
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)

2.5/alpine3.10/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,11 @@ RUN set -eux; \
124124
# install things globally, for great justice
125125
# and don't create ".bundle" in all our apps
126126
ENV GEM_HOME /usr/local/bundle
127+
ENV GEM_PATH $GEM_HOME/ruby/$RUBY_MAJOR.0:$GEM_PATH
127128
ENV BUNDLE_PATH="$GEM_HOME" \
128129
BUNDLE_SILENCE_ROOT_WARNING=1 \
129130
BUNDLE_APP_CONFIG="$GEM_HOME"
130-
ENV PATH $GEM_HOME/bin:$PATH
131+
ENV PATH $GEM_HOME/bin:$GEM_HOME/ruby/$RUBY_MAJOR.0/bin:$PATH
131132
# adjust permissions of a few directories for running "gem install" as an arbitrary user
132133
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
133134
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)

2.5/alpine3.11/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,11 @@ RUN set -eux; \
124124
# install things globally, for great justice
125125
# and don't create ".bundle" in all our apps
126126
ENV GEM_HOME /usr/local/bundle
127+
ENV GEM_PATH $GEM_HOME/ruby/$RUBY_MAJOR.0:$GEM_PATH
127128
ENV BUNDLE_PATH="$GEM_HOME" \
128129
BUNDLE_SILENCE_ROOT_WARNING=1 \
129130
BUNDLE_APP_CONFIG="$GEM_HOME"
130-
ENV PATH $GEM_HOME/bin:$PATH
131+
ENV PATH $GEM_HOME/bin:$GEM_HOME/ruby/$RUBY_MAJOR.0/bin:$PATH
131132
# adjust permissions of a few directories for running "gem install" as an arbitrary user
132133
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
133134
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)

2.5/buster/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ RUN set -eux; \
8383
# install things globally, for great justice
8484
# and don't create ".bundle" in all our apps
8585
ENV GEM_HOME /usr/local/bundle
86+
ENV GEM_PATH $GEM_HOME/ruby/$RUBY_MAJOR.0:$GEM_PATH
8687
ENV BUNDLE_PATH="$GEM_HOME" \
8788
BUNDLE_SILENCE_ROOT_WARNING=1 \
8889
BUNDLE_APP_CONFIG="$GEM_HOME"
89-
ENV PATH $GEM_HOME/bin:$PATH
90+
ENV PATH $GEM_HOME/bin:$GEM_HOME/ruby/$RUBY_MAJOR.0/bin:$PATH
9091
# adjust permissions of a few directories for running "gem install" as an arbitrary user
9192
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
9293
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)

2.5/buster/slim/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ RUN set -eux; \
109109
# install things globally, for great justice
110110
# and don't create ".bundle" in all our apps
111111
ENV GEM_HOME /usr/local/bundle
112+
ENV GEM_PATH $GEM_HOME/ruby/$RUBY_MAJOR.0:$GEM_PATH
112113
ENV BUNDLE_PATH="$GEM_HOME" \
113114
BUNDLE_SILENCE_ROOT_WARNING=1 \
114115
BUNDLE_APP_CONFIG="$GEM_HOME"
115-
ENV PATH $GEM_HOME/bin:$PATH
116+
ENV PATH $GEM_HOME/bin:$GEM_HOME/ruby/$RUBY_MAJOR.0/bin:$PATH
116117
# adjust permissions of a few directories for running "gem install" as an arbitrary user
117118
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
118119
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)

0 commit comments

Comments
 (0)