Reputation: 2279
I recently install ruby 2.7.1 using rbenv. I have made sure that .ruby-version
and Gemfile file both have 2.7.1 as ruby version.
Now i cannot run rails s locally, doing so returns the following output in console:
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running
gem install bundler:2.1.4
.
Your Ruby version is 2.7.0, but your Gemfile specified 2.7.1
I have been searching and trying different things for hours but cannot figure out the problem and would be thankful for help.
Following output may help figure out the problem:
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for
rbenv' in PATH: /usr/bin/rbenv Checking for rbenv shims in PATH: OK Checking
rbenv install' support: /home/imran/.rbenv/plugins/ruby-build/bin/rbenv-install (ruby-build 20200819)
Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK
bundle env
Bundler 2.1.4
Platforms ruby, x86_64-linux
Ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9cec0d0ffcba012279cd652d28ad5bf3) [x86_64-linux]
Full Path /home/imran/.rbenv/versions/2.7.1/bin/ruby
Config Dir /home/imran/.rbenv/versions/2.7.1/etc
RubyGems 3.1.2
Gem Home /home/imran/.gem/ruby/2.7.0
Gem Path /home/imran/.gem/ruby/2.7.0:/home/imran/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
User Home /home/imran
User Path /home/imran/.gem/ruby/2.7.0
Bin Dir /home/imran/.gem/ruby/2.7.0/bin
Tools
Git 2.25.1
RVM not installed
rbenv rbenv 1.1.1
chruby not installed
Built At 2020-01-05
Git SHA 32a4159325
Released Version true
gem env
RubyGems Environment:
my ~/.profile
contains following statements:
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$HOME/.rbenv/bin:$PATH"
Upvotes: 0
Views: 951
Reputation: 822
rbenv
creates shims based on version of ruby you install. Each time you change ruby version via rbenv global X.Y.Z
or rbenv local A.B.C
, rbenv will intercept the ruby command and redirect it to the appropriate ruby installation version which will look at its associated gems.
Therefore, if you set your local version to 2.7.1
, and the error message you receive is telling you that your bundle version is different, you probably have not installed the bundler
gem in the 2.7.1
Ruby shim.
To fix this, you can change your ruby version and install the gem:
rbenv local 2.7.1
ruby -v
# 2.7.1
gem install bundler
Now, ensure that in your Gemfile.lock you are using the same bundler
version of the bundler gem you installed. If it is not, it means that the Gemfile.lock
file was generated and bundled with a previous version. You can force update the Gemfile.lock
by deleting and rebuilding, however, if you are collaborating with other developers you may want to speak with them before you do (and commit to source control)
#Gemfile.lock
BUNDLED_WITH 2.1.5
Upvotes: 0
Reputation: 217
Did You try to just update bundler as output said:
gem install bundler:2.1.4
or
gem install bundler
bundle update
Upvotes: 0