Search code examples
ruby-on-railsrubybundler

Two versions of bundler installed and using the wrong one


I have the right version of Bundler installed:

docker@f5990915a8ae:/usr/src/app$ bundler version
Bundler version 2.2.17 (2021-05-05 commit 69cbd6e10e)

But when I run the db:migrate it seems that is using another one:

Warning: the running version of Bundler (2.1.4) is older than the version that created the lockfile (2.2.17). We suggest you to upgrade to the version that created the lockfile by running gem install bundler:2.2.17.

This is my gem environment for the app:

RubyGems Environment:
  - RUBYGEMS VERSION: 3.1.2
  - RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [x86_64-linux-gnu]
  - INSTALLATION DIRECTORY: /home/docker/.gem
  - USER INSTALLATION DIRECTORY: /home/docker/.gem/ruby/2.7.0
  - RUBY EXECUTABLE: /usr/bin/ruby2.7
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /home/docker/.gem/bin
  - SPEC CACHE DIRECTORY: /home/docker/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/docker/.gem
     - /home/docker/.gem/ruby/2.7.0
     - /var/lib/gems/2.7.0
     - /usr/lib/x86_64-linux-gnu/rubygems-integration/2.7.0
     - /usr/share/rubygems-integration/2.7.0
     - /usr/share/rubygems-integration/all
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-document"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/docker/.gem//bin
     - /home/docker/.gem/ruby/2.7.0/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin

These are the two bundler versions installed:

home/docker/.gem/specifications/bundler-2.2.17.gemspec
usr/lib/ruby/gems/2.7.0/specifications/default/bundler-2.1.4.gemspec

How do I make the db:migrate use the right one?


Solution

  • change to

    bundle exec rake db:migrate
    

    or change bundler version in Gemfile.lock