Serverspecを実行した際にエラーが発生して、しばらくウンウン悩んでしまったので残しておく。

[code]
Running Tests on testweb
Vagrant experienced a version conflict with some installed plugins!
This usually happens if you recently upgraded Vagrant. As part of the
upgrade process, some existing plugins are no longer compatible with
this version of Vagrant. The recommended way to fix this is to remove
your existing plugins and reinstall them one-by-one. To remove all
plugins:

rm -r ~/.vagrant.d/plugins.json ~/.vagrant.d/gems

Note if you have an alternate VAGRANT_HOME environmental variable
set, the folders above will be in that directory rather than your
user's home directory.

The error message is shown below:

Bundler could not find compatible versions for gem ‘bundler’:
In Gemfile:
vagrant (= 1.8.1) was resolved to 1.8.1, which depends on
bundler (>= 1.10.6, <= 1.5.2)

Current Bundler version:
bundler (1.12.5)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?

Could not find gem ‘bundler (<= 1.10.6, >= 1.5.2)&#39;, which is required by gem ‘vagrant (= 1.8.1)’, in any of the sources.

Failures:

1) Package nginx; should be installed
On host `testweb’;
Failure/Error: it { should be_installed }
Errno::ECONNREFUSED:

[/code]

対処方法

検索して一番上にgs3のブログが出てきたので参考にした。感謝。

[code]
gem install bundler -v 1.10.5
Fetching: bundler-1.10.5.gem (100%)
Successfully installed bundler-1.10.5
Parsing documentation for bundler-1.10.5
Installing ri documentation for bundler-1.10.5
1 gem installed
[/code]

bundlerはバージョンが低いものがインストールされたように見えるが、テストに失敗した。

[code]
gem list bundler

*** LOCAL GEMS ***

bundler (1.12.5, 1.10.5)
[/code]

2つはいってしまってる。
切り分けのために新しい方を削除した。

[code]
gem uninstall bundler -v 1.12.5
Successfully uninstalled bundler-1.12.5

gem list bundler

*** LOCAL GEMS ***

bundler (1.10.5)
[/code]

テストを実行する。

[code]
running Tests on testweb
……….

Finished in 0.57037 seconds (files took 3.13 seconds to load)
10 examples, 0 failures
[/code]

テストが通るようになった。
rubyの環境設定周り、特にbundleとかgemとか理解が浅いので、しっかり理解していったほうが良さそうだ。
バージョンの違うgemが入った場合に、どちらを使うとか指定できるのか分からなかったので、とりあえずは都度バージョン指定インストールしたり、削除したりしていこうと思う。
bundlerの使い方については、公式ドキュメントを翻訳したサイトがあって、大変わかり易く説明してあるので熟読したい。

http://ruby.studio-kingdom.com/bundler/

カテゴリー: DailyTech