はじめに
先日、とある理由で32bit版Windowsホスト向けに32bit版CentOS6のVagrant Boxファイルを自作することになったのですが、
Windowsホスト上でのvagrant box add コマンドがエラーとなり、
少々ハマリましたので自分用のメモも兼ねて記事を書きます。
Windowsホスト上でのvagrant利用は初めてだったので、
当初はpackageファイルの作成失敗を疑いましたが、原因は違うところにありました。
環境
種別 | Ver. |
---|---|
ホストOS | Windows7 / windows2012 |
VirtualBox | 5.0.20 r106931 |
Vagrant | 1.8.1 |
事象
Windowsホスト上で作成したCentoS6のpackage.boxファイルより
vagrant box addをしようとしたところ、以下エラーにより失敗します。
C:\Users\vagrant\Desktop\winenv>vagrant box add Centos67-32 package.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'Centos67-32' (v0) for provider:
box: Unpacking necessary files from: file://C:/Users/vagrant/Desktop/winenv/
package.box
box:
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.
原因
VC++の再頒布可能パッケージ が不足しているため、boxファイルのダウンロード(ローカル環境でも)に失敗しているようです。
対応
vcredist_x86.exe:Microsoft Visual C++ 2010 再頒布可能パッケージ (x86)をリンク先からダウンロードして
インストールしてから、再度vagrant box add コマンドを実行します。
試していませんが、64bitの場合はMicrosoft Visual C++ 2010 再頒布可能パッケージ (x64) のようです。
また、こちらも試していませんがOS種類によってはVisual Studio 2013 の Visual C++ 再頒布可能パッケージが正解かもしれません。
実行結果
C:\Users\vagrant\Desktop\winenv>vagrant box add Centos67-32 package.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'Centos67-32' (v0) for provider:
box: Unpacking necessary files from: file://C:/Users/vagrant/Desktop/winenv/package.box
box: Progress: 100% (Rate: 118M/s, Estimated time remaining: --:--:--)
==> box: Successfully added box 'Centos67-32' (v0) for 'virtualbox'!
C:\Users\vagrant\Desktop\winenv>vagrant box list
Centos67-32 (virtualbox, 0)
C:\Users\vagrant\Desktop\winenv>
おわりに
今までLinuxやOSX版のVagrantはさわっていたのですが、Windows版Vagrantは今回が初めてでした。
一部vagrant sshコマンドがそのままでは通らないなど、Linux系とは異なるところもありますが、
思った以上にそのままの操作性で使えたのはびっくりでした。やっぱりVagrantすごいですね。