I am trying to install bundler version 2.1
in a docker image that is built from ruby:2.4.1
. My Docker file looks the following way:
FROM ruby:2.4.1
RUN \
gem update --system --quiet && \
gem install bundler -v '~> 2.1'
# Other commands
But when I try to run bundle install
it fails with
You must use Bundler 2 or greater with this lockfile.
When I run inside a container gem info bundler
it outputs:
bundler (2.1.2, 1.15.4)
Authors: André Arko, Samuel Giddins, Colby Swandale, Hiroshi
Shibata, David Rodríguez, Grey Baker, Stephanie Morillo, Chris
Morris, James Wen, Tim Moore, André Medeiros, Jessica Lynn Suttles,
Terence Lee, Carl Lerche, Yehuda Katz
Homepage: https://bundler.io
License: MIT
Installed at (2.1.2): /usr/local/bundle
(1.15.4): /usr/local/lib/ruby/gems/2.4.0
I tried the following fixes:
# Set bundler 2.1.2 as default
bundler config default 2.1.2
# Update bundler
gem update bundler
But they didn't work. The system continues to use bundler v1.15.4
How can I make bundler v2.1.2
as default inside a ruby docker image?
I was able to switch to bundler version 2.1 in my docker image using the following commands:
# Dockerfile
RUN \
gem update --system --quiet && \
gem install bundler -v '~> 2.1'
ENV BUNDLER_VERSION 2.1