チームでVagrantを利用してると、各環境のバージョンが違って予期せぬトラブルが起きたので対応策を共有しておきます.
これでバージョン違いでチームメンバーからのクレームが少なくなると思います.
警告を表示
チームメンバーが複数のプロジェクトを掛け持ちしている場合、
Vagrantのバージョンを固定するのは難しいのでオススメの対策は警告を表示することです.
Vagrantfile
if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new('1.6.5')
STDERR.puts "\e[33m[ WARNING ]\e[0m Please install vagrant 1.6.5"
STDERR.puts "\e[33m[ WARNING ]\e[0m Current vagrant version : #{Vagrant::VERSION}"
end
エラーを表示して終了
有無を言わさず指定したバージョン以上のみはメッセージを出して終了させちゃいましょう.
Vagrantfile
# 1.6.5以上
Vagrant.require_version(">= 1.6.5")
# 1.3.5以上1.5.6未満
# Vagrant.require_version(">= 1.3.5", "< 1.5.6")
# 1.6.5以上1.7未満
# Vagrant.require_version("~> 1.6.5")
エラーメッセージ
This Vagrant environment has specified that it requires the Vagrant
version to satisfy the following version requirements:
>= 1.6.5
You are running Vagrant 1.6.3, which does not satisfy
these requirements. Please change your Vagrant version or update
the Vagrantfile to allow this Vagrant version. However, be warned
that if the Vagrantfile has specified another version, it probably has
good reason to do so, and changing that may cause the environment to
not function properly.