0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

activeadminが原因でbundle installができない

Last updated at Posted at 2017-11-24

#はじめに
本日はお日柄もよく(以下略).
さて、他所で作ったrailsのプロジェクトをgitからcloneしてきて、自分のPCで環境構築しようとするとなぜかできない・・・.

#PC環境
PC: MacBook Pro
OS: macOS High Sierra 10.13.31
brew install済み
rbenvでrubyをversion 2.2.6に設定

#rails環境構築
railsで環境構築をする際にはGemfileで環境を設定します.
Gemfileはこんな感じになってるはず↓

Gemfile
source 'https://rubygems.org'
# ruby '2.1.2'

gem 'rails', '4.1.2'
~~(省略)~~
gem 'activeadmin', github: 'activeadmin'
gem 'rails-i18n', '~> 4.0.0'
gem 'clockwork'
gem 'enum_help'
gem 'kaminari',
~~(省略)~~

group :development do
  gem 'spring', '~> 1.1.2'
  gem 'spring-commands-rspec'
  ~~(省略)~~
end

group :development, :test do
  gem 'factory_girl_rails', '4.2.1'
  gem 'database_cleaner', github: 'bmabey/database_cleaner'
  gem 'capybara', '~> 2.2.0'
  gem 'rspec-rails'
  gem 'guard'
  gem 'guard-rspec', '~> 4.2.8'
  ~~(省略)~~
end

そしてこれを反映させるのにGemfileのあるディレクトリで、

$ bundle install --path vendor/bundle

を実行. すると

Fetching https://github.com/gregbell/active_admin.git
Fetching https://github.com/bmabey/database_cleaner.git
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Bundler could not find compatible versions for gem "kaminari":
  In snapshot (Gemfile.lock):
    kaminari (= 0.17.0)

  In Gemfile:
    kaminari

    activeadmin was resolved to 2.0.0.alpha, which depends on
      kaminari (>= 1.0.1)

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

ありゃ、エラーがでた.
kaminariのversionが違うからコンフリクトが起きているようだ.プロジェクトを作成したPCでは問題なく通ったのだが・・・.

一度指示通り

bundle update

をしてみたがエラーが増えるだけで根本的に解決に結びつかなかった.

先ほどのエラーメッセージをよく読んでみるとactiveadminは2.0.0.alphaであり,それが参照するkaminariがGemfile.lockのものとうまく対応してないっぽい.

つまり、activeadminのversionをうまく変えればなんとかなりそうです.

ここではプロジェクトを作成したPCのactiveadminが1.0.0.pre4だったのでそれを指定する.

Gemfile
source 'https://rubygems.org'
# ruby '2.1.2'

gem 'rails', '4.1.2'
~~(省略)~~
#gem 'activeadmin', github: 'activeadmin' 
gem 'activeadmin', '~> 1.0.0.pre4' #ここ変更
gem 'rails-i18n', '~> 4.0.0'
gem 'clockwork'
gem 'enum_help'
gem 'kaminari',
~~(省略)~~

group :development do
  gem 'spring', '~> 1.1.2'
  gem 'spring-commands-rspec'
  ~~(省略)~~
end

group :development, :test do
  gem 'factory_girl_rails', '4.2.1'
  gem 'database_cleaner', github: 'bmabey/database_cleaner'
  gem 'capybara', '~> 2.2.0'
  gem 'rspec-rails'
  gem 'guard'
  gem 'guard-rspec', '~> 4.2.8'
  ~~(省略)~~
end

これで bundle install --path vendor/bundle を実行すると

Fetching https://github.com/bmabey/database_cleaner.git
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies....
Fetching rake 10.5.0
Installing rake 10.5.0
Fetching i18n 0.7.0
Installing i18n 0.7.0
Fetching json 1.8.3
Installing json 1.8.3 with native extensions
Fetching minitest 5.10.1
~~(省略)~~
Fetching unicorn 5.2.0
Installing unicorn 5.2.0 with native extensions
Bundle complete! 64 Gemfile dependencies, 147 gems now installed.
Bundled gems are installed into `./vendor/bundle`

よし通った!

#考えられる原因
あとで調べてみたところ、どうやらbundleのversion違いが原因かもしれない.
プロジェクトを作成した方は 1.15.~系だったのに対し,今回のPCは 1.16系であった.
変更前はactiveadminをgitから参照していたが、bundleのversionの違いにより参照先が異なっている可能性がある.

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?