rails -vやrails sでincompatible library versionとエラーが出る
アプリ作成の初期段階で、以下コマンドを完了した後、rails -vやrails sをしたところincompatible library version
とエラーが出た為、解決方法を残しておきます。
完了したコマンド
$ bundle init
$ Gemfile内に以下を記載
ruby '2.6.4' gem 'rails', '~> 5.2.6'
$ bundle install --path vendor/bundle
$ bundle exec rails new . -d mysql --skip-coffee --skip-turbolinks
$ git add .
$ git commit -m "initial commit"
$ git flow init
$ git push --all
$ git flow feature start 01_hogehogebranch
エラーコード
% rails -v Traceback (most recent call last): 15: from bin/rails:3:in `<main>' 14: from bin/rails:3:in `require_relative' 13: from /Users/xxxxxxxxxx/workspace/insta_clone/config/boot.rb:4:in `<top (required)>' 12: from /Users/xxxxxxxxxx/workspace/insta_clone/config/boot.rb:4:in `require' 11: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/setup.rb:2:in `<top (required)>' 10: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/setup.rb:2:in `require_relative' 9: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap.rb:5:in `<top (required)>' 8: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap.rb:5:in `require_relative' 7: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache.rb:61:in `<top (required)>' 6: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache.rb:61:in `require_relative' 5: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/store.rb:4:in `<top (required)>' 4: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/explicit_require.rb:41:in `with_gems' 3: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/store.rb:4:in `block in <top (required)>' 2: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/store.rb:4:in `require' 1: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/msgpack-1.4.2/lib/msgpack.rb:8:in `<top (required)>' /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/msgpack-1.4.2/lib/msgpack.rb:8:in `require': incompatible library version - /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle (LoadError) 16: from bin/rails:3:in `<main>' 15: from bin/rails:3:in `require_relative' 14: from /Users/xxxxxxxxxx/workspace/insta_clone/config/boot.rb:4:in `<top (required)>' 13: from /Users/xxxxxxxxxx/workspace/insta_clone/config/boot.rb:4:in `require' 12: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/setup.rb:2:in `<top (required)>' 11: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/setup.rb:2:in `require_relative' 10: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap.rb:5:in `<top (required)>' 9: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap.rb:5:in `require_relative' 8: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache.rb:61:in `<top (required)>' 7: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache.rb:61:in `require_relative' 6: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/store.rb:4:in `<top (required)>' 5: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/explicit_require.rb:40:in `with_gems' 4: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/explicit_require.rb:44:in `rescue in with_gems' 3: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/store.rb:4:in `block in <top (required)>' 2: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/store.rb:4:in `require' 1: from /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/msgpack-1.4.2/lib/msgpack.rb:8:in `<top (required)>' /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/msgpack-1.4.2/lib/msgpack.rb:8:in `require': incompatible library version - /Users/xxxxxxxxxx/workspace/insta_clone/vendor/bundle/ruby/2.6.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle (LoadError) Gem-file source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.6.4' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.6' # Use mysql as the database for Active Record gem 'mysql2', '>= 0.4.4', '< 0.6.0' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use ActiveStorage variant # gem 'mini_magick', '~> 4.8' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome gem 'chromedriver-helper' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
試したこと
以下いくつか確認しました。
・ローカルのrubyが2.6.4と確認。
% rbenv local 2.6.4 % rbenv global system
・which rubyとwhich bundleも同じ階層にいることを確認。
% which ruby /Users/xxxxxxxxx/.anyenv/envs/rbenv/shims/ruby % which bundle /Users/xxxxxxxxx/.anyenv/envs/rbenv/shims/bundle
・他のRailsプロジェクトではrails -vが問題なく作動することを確認
・rbenv rehash
を実行後再度bundle install --path vendor/bundle
を実行したが変化なし
・gem update --system
を実行したが変化なし
・rubyを一度uninstall
して再度install → bundle install --path vendor/bundle
を実行したが変化なし
解決できた方法
vendor/bundle
ディレクトリ以下を全削除してから再度bundle install --path vendor/bundle
をしたところエラーがなくなりrails -vやrails sが動作するようになりました!