[Mac] Vagrantを2.0.1にアップデートした際のトラブル対応

概要

Macで新しく開発を行うために、既存のVagrant環境のzipを受け取り、環境構築をしようとしたところで幾つかのトラブルに見舞われたのでその解決方法の備忘録を残す。

対応内容とエラーメッセージは以下の通り。

① Vagrantのバージョンが古い問題

This Vagrant environment has specified that it requires the Vagrant
version to satisfy the following version requirements:

>= 1.9.0

You are running Vagrant 1.8.6, 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.

② プラグインが古い問題

Vagrant failed to initialize at a very early stage:

The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:

vagrant plugin repair

If Vagrant was recently updated, this error may be due to incompatible
versions of dependencies. To fix this problem please remove and re-install
all plugins. Vagrant can attempt to do this automatically by running:

vagrant plugin expunge --reinstall

Or you may want to try updating the installed plugins to their latest
versions:

vagrant plugin update

Error message given during initialization: Unable to resolve dependency: user requested 'vagrant-vbguest (> 0)'

③ VMの作成者が違う問題

The VirtualBox VM was created with a user that doesn't match the
current user running Vagrant. VirtualBox requires that the same user
be used to manage the VM that was created. Please re-run Vagrant with
that user. This is not a Vagrant issue.

The UID used to create the VM was: 503
Your UID is: 501

前提

以下の環境で動作確認

Mac Book Air 10.12.6
vagrant(更新前) 1.8.6
vagrant(更新後) 2.0.1

Vagrantのバージョンが古い問題

vagran1.8.6で、新しい開発環境用のVMを起動しようとした所、以下のエラーメッセージが表示された。

$ vagrant up
This Vagrant environment has specified that it requires the Vagrant
version to satisfy the following version requirements:

>= 1.9.0

You are running Vagrant 1.8.6, 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.

どうやら対象のVMはvagrant1.9.0以上が要求されているらしいが、Macには1.8.6しか入ってないので起動できないらしい。

VM側を弄るという手もあるが、いつまでも古いバージョンのvagrantを使っていてもアレなので、この機会にvagrantをアップデートする。

Download Vagrantより、Mac用のdmgファイルをダウンロードして、あとは普通にインストールする。

最新版が入った。

$ vagrant --version
Vagrant 2.0.1

プラグインが古い問題

vagrantのバージョンをあげたので、これでVMも起動すると思ったが、今度は以下のエラーが出た。

$ vagrant up
Vagrant failed to initialize at a very early stage:

The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:

vagrant plugin repair

If Vagrant was recently updated, this error may be due to incompatible
versions of dependencies. To fix this problem please remove and re-install
all plugins. Vagrant can attempt to do this automatically by running:

vagrant plugin expunge --reinstall

Or you may want to try updating the installed plugins to their latest
versions:

vagrant plugin update

Error message given during initialization: Unable to resolve dependency: user requested 'vagrant-vbguest (> 0)'

どうやらVagrantのプラグインの方のバージョンも引き上げなきゃならない模様。

指示通りプラグインをアップデートする。

$ vagrant plugin update
Updating installed plugins...
Fetching: vagrant-share-1.1.9.gem (100%)
Updated 'vagrant-vbguest' to version '0.15.0'!

こちらの環境ではコレで問題なかったが、updateコマンドが上手く動かない場合、Vagrant 1.9.0に更新したらエラーが発生?を参考に、既存のプラグインを削除すると動くらしい。

VMの作成者が違う問題

今度こそVM起動。と思ったら以下のエラーが出た。

$ vagrant up
The VirtualBox VM was created with a user that doesn't match the
current user running Vagrant. VirtualBox requires that the same user
be used to manage the VM that was created. Please re-run Vagrant with
that user. This is not a Vagrant issue.

The UID used to create the VM was: 503
Your UID is: 501

これは他の人が作成したVagrant用ディレクトリをそのまま受け取った場合に発生しがち。
作成者のUIDと、現在のUIDが違うことで上記のエラーが出るらしい。なので作成者のUIDを、自身のUIDにすることで解決する。

作成者のUIDは、

.vagrant/machines/[VM名 or default]/virtualbox/creator_uid

にあるので、そのファイルを、エラーメッセージに含まれている自身のUID(上記の場合501)に書き換える。

以上の手順でようやく起動した。

$ vagrant up
Bringing machine 'hogehoge' up with 'virtualbox' provider...
==> hogehoge: Box 'hogehoge' could not be found. Attempting to find and install...
hogehoge: Box Provider: virtualbox
hogehoge: Box Version: >= 0
==> hogehoge: Box file was not detected as metadata. Adding it directly...
==> hogehoge: Adding box 'hogehoge' (v0) for provider: virtualbox
hogehoge: Unpacking necessary files from: file:///Users/fuga/hoge/box/hoge.box
==> hogehoge: Successfully added box 'hogehoge' (v0) for 'virtualbox'!

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です