Rails5 でbundle installをするときにバージョンコンフリクトでつまったメモ

  • 6
    いいね
  • 0
    コメント

Rails tutorialも標準でRails 5に対応しましたね。

今回bundle installをする時バージョンコンフリクトで詰まったので自分用のメモ

通常通りRails5をGemでインストールする時、

gem
$ sudo gem install rails -v 5.0.0.1
実行結果
Successfully installed rails-5.0.0.1
Parsing documentation for rails-5.0.0.1
Done installing documentation for rails after 0 seconds
1 gem installed

でインストール後

rails
$ rails _5.0.0.1_ new hello_odenn
実行結果
create  
      create  README.md
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/config/manifest.js
      create  app/assets/javascripts/application.js
      create  app/assets/javascripts/cable.js
      create  app/assets/stylesheets/application.css
      create  app/channels/application_cable/channel.rb
      create  app/channels/application_cable/connection.rb
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/jobs/application_job.rb
      create  app/mailers/application_mailer.rb
      create  app/models/application_record.rb
      create  app/views/layouts/application.html.erb
      create  app/views/layouts/mailer.html.erb
      create  app/views/layouts/mailer.text.erb
      create  app/assets/images/.keep
      create  app/assets/javascripts/channels
      create  app/assets/javascripts/channels/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
      create  bin/setup
      create  bin/update
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/secrets.yml
      create  config/cable.yml
      create  config/puma.rb
      create  config/spring.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/application_controller_renderer.rb
      create  config/initializers/assets.rb
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/cookies_serializer.rb
      create  config/initializers/cors.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/new_framework_defaults.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/apple-touch-icon-precomposed.png
      create  public/apple-touch-icon.png
      create  public/favicon.ico
      create  public/robots.txt
      create  test/fixtures
      create  test/fixtures/.keep
      create  test/fixtures/files
      create  test/fixtures/files/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/test_helper.rb
      create  tmp
      create  tmp/.keep
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.keep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.keep
      remove  config/initializers/cors.rb
         run  bundle install
========略==========
         run  bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted


その後Gemfileを編集

ruby
source 'https://rubygems.org'

gem 'rails',        '5.0.0.1'
gem 'puma',         '3.4.0'
gem 'sass-rails',   '5.0.6'
gem 'uglifier',     '3.0.0'
gem 'coffee-rails', '4.2.1'
gem 'jquery-rails', '4.1.1'
gem 'turbolinks',   '5.0.1'
gem 'jbuilder',     '2.4.1'

group :development, :test do
  gem 'sqlite3', '1.3.11'
  gem 'byebug',  '9.0.0', platform: :mri
end

group :development do
  gem 'web-console',           '3.1.1'
  gem 'listen',                '3.0.8'
  gem 'spring',                '1.7.2'
  gem 'spring-watcher-listen', '2.0.0'
end

group :production do
  gem 'pg', '0.18.4'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

編集後

ruby
$ bundle install

を実行後にエラーを吐き出しました。(バージョンがコンフリクトしているとのこと)

実行結果
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies...
Bundler could not find compatible versions for gem "activesupport":
  In snapshot (Gemfile.lock):
    activesupport (= 5.0.1)

  In Gemfile:
    rails (= 5.0.0.1) was resolved to 5.0.0.1, which depends on
      activejob (= 5.0.0.1) was resolved to 5.0.0.1, which depends on
        globalid (>= 0.3.6) was resolved to 0.3.7, which depends on
          activesupport (>= 4.1.0)

    jbuilder (= 2.4.1) was resolved to 2.4.1, which depends on
      activesupport (< 5.1, >= 3.0.0)

    rails (= 5.0.0.1) was resolved to 5.0.0.1, which depends on
      activesupport (= 5.0.0.1)

    rails (= 5.0.0.1) was resolved to 5.0.0.1, which depends on
      activesupport (= 5.0.0.1)

    rails (= 5.0.0.1) was resolved to 5.0.0.1, which depends on
      activesupport (= 5.0.0.1)

    rails (= 5.0.0.1) was resolved to 5.0.0.1, which depends on
      activesupport (= 5.0.0.1)

    rails (= 5.0.0.1) was resolved to 5.0.0.1, which depends on
      actionmailer (= 5.0.0.1) was resolved to 5.0.0.1, which depends on
        rails-dom-testing (~> 2.0) was resolved to 2.0.2, which depends on
          activesupport (< 6.0, >= 4.2.0)

    rails (= 5.0.0.1) was resolved to 5.0.0.1, which depends on
      sprockets-rails (>= 2.0.0) was resolved to 3.2.0, which depends on
        activesupport (>= 4.0)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

いろいろ試した結果

ruby
$ gem list
実行結果

*** LOCAL GEMS ***

actioncable (5.0.1, 5.0.0.1)
actionmailer (5.0.1, 5.0.0.1, 4.2.5, 4.2.2)
actionpack (5.0.1, 5.0.0.1, 4.2.5, 4.2.2)
actionview (5.0.1, 5.0.0.1, 4.2.5, 4.2.2)
activejob (5.0.1, 5.0.0.1, 4.2.5, 4.2.2)
activemodel (5.0.1, 5.0.0.1, 4.2.5, 4.2.2)
activerecord (5.0.1, 5.0.0.1, 4.2.5, 4.2.2)
activesupport (5.0.1, 5.0.0.1, 4.2.5, 4.2.2)

とバージョンがなぜか5.0.1入っており5.0.0.1とコンフリクトを起こしていたのが原因

ruby
$ sudo gem cleanup
実行結果
Cleaning up installed gems...
Attempting to uninstall will_paginate-3.0.7
Successfully uninstalled will_paginate-3.0.7
Attempting to uninstall web-console-2.0.0.beta3
Successfully uninstalled web-console-2.0.0.beta3
Attempting to uninstall web-console-2.3.0
Successfully uninstalled web-console-2.3.0
Attempting to uninstall web-console-3.3.1
Successfully uninstalled web-console-3.3.1
Attempting to uninstall uuidtools-2.1.4
Unable to uninstall uuidtools-2.1.4:
    Gem::InstallError: uuidtools is not installed in GEM_HOME, try:
    gem uninstall -i /usr/share/rubygems-integration/all uuidtools
Attempting to uninstall uglifier-3.0.2
Successfully uninstalled uglifier-3.0.2
Attempting to uninstall uglifier-3.0.3
Successfully uninstalled uglifier-3.0.3
Attempting to uninstall turbolinks-2.3.0
Successfully uninstalled turbolinks-2.3.0
Attempting to uninstall sqlite3-1.3.9
Successfully uninstalled sqlite3-1.3.9
Attempting to uninstall sqlite3-1.3.11
Successfully uninstalled sqlite3-1.3.11
Attempting to uninstall sqlite3-1.3.12
Successfully uninstalled sqlite3-1.3.12
Attempting to uninstall sprockets-rails-3.0.4
Successfully uninstalled sprockets-rails-3.0.4
Attempting to uninstall sprockets-3.6.0
Successfully uninstalled sprockets-3.6.0
Attempting to uninstall spring-watcher-listen-2.0.0
Successfully uninstalled spring-watcher-listen-2.0.0
Attempting to uninstall spring-1.1.3
Successfully uninstalled spring-1.1.3
Attempting to uninstall spring-2.0.0
Successfully uninstalled spring-2.0.0
Attempting to uninstall slop-4.2.0
Unable to uninstall slop-4.2.0:
    Gem::InstallError: slop is not installed in GEM_HOME, try:
    gem uninstall -i /usr/share/rubygems-integration/all slop
Attempting to uninstall serverspec-2.18.0
Unable to uninstall serverspec-2.18.0:
    Gem::InstallError: serverspec is not installed in GEM_HOME, try:
    gem uninstall -i /usr/share/rubygems-integration/all serverspec
Attempting to uninstall specinfra-2.35.1
Unable to uninstall specinfra-2.35.1:
    Gem::InstallError: specinfra is not installed in GEM_HOME, try:
    gem uninstall -i /usr/share/rubygems-integration/all specinfra
以下略

で解決しました。
バージョン衝突とか怖すぎて真っ青になったので
書くほどのことでも無いですが一応残しておきます。
お役に立てれば幸いです。