I got an error in the title when I was touching Ruby, so I wrote it as an article.
I ran into an error with
bundle install while touching an app that was in the process of being created.
$ bundle install -> Ruby version is 2.6.3, but your Gemfile specified 2.5.8
From the error statement, I can think that the version of Ruby and the version specified by Gemfile are different.
First, let's check the version of Ruby.
$ ruby -v -> ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-darwin19]
Since rbenv is used, check there as well
$ rbenv versions system 2.1.5 2.5.1 * 2.5.8 2.6.3 2.7.1
It looks like it looks right.
Let's check with
gem environment where you can refer to the path of Ruby you are using now.
$ gem environment -> RubyGems Environment: - RUBYGEMS VERSION: 188.8.131.52 - RUBY VERSION: 2.5.8 (2020-03-31 patchlevel 224) [x86_64-darwin19] - INSTALLATION DIRECTORY: /Users/username/.rbenv/gems/2.5.0 - USER INSTALLATION DIRECTORY: /Users/username/.gem/ruby/2.5.0 - RUBY EXECUTABLE: /Users/username/.rbenv/versions/2.5.8/bin/ruby - EXECUTABLE DIRECTORY: /Users/username/.rbenv/gems/2.5.0/bin - SPEC CACHE DIRECTORY: /Users/username/.gem/specs - SYSTEM CONFIGURATION DIRECTORY: /Users/username/.rbenv/versions/2.5.8/etc - RUBYGEMS PLATFORMS: - ruby - x86_64-darwin-19 - GEM PATHS: - /Users/username/.rbenv/gems/2.5.0 - GEM CONFIGURATION: ...(Continue)
Well, it looks like it's not wrong ...
Check the location of the bundle
$ which bundle -> /usr/local/bin/bundle
Take a look at the contents
-> % cat /usr/local/bin/bundle #!/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby # # This file was generated by RubyGems. # # The application 'bundler' is installed as part of a gem, and # this file is here to facilitate running it. # require 'rubygems' version = ">= 0.a" str = ARGV.first if str str = str.b[/\A_(.*)_\z/, 1] if str and Gem::Version.correct?(str) version = str ARGV.shift end end ...(Continue)
Oh, I'm referring to
$ which ruby /Users/username/.rbenv/shims/ruby
Changed the reference to
bundle install has passed successfully!