読者です 読者をやめる 読者になる 読者になる

MacでVagrant1.8.7にしたらvagrant box add / initがうまくできなくなった話

mac vagrant linux

MacでVagrant1.8.7にしたらvagrant box add / initがうまくできなくなった。 vagrantを開発・検証環境用に多用していて困るので、なんとか解決した話。

環境は。

Vagrant 1.8.7

ホストOS

OS X 10.11.6(El Capitan)

作成したvagrant boxを追加しようと。

vagrant box add package.box --name <box名>

といつものようにコマンドを打つと。

An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

なるエラーがでるじゃないですか。

なんだと思いつつvagrantデバッグログを出力設定。

export VAGRANT_LOG=DEBUG

再度同じようにコマンドを入力すると。

DEBUG subprocess: Selecting on IO
DEBUG subprocess: stderr: dyld: Library not loaded: @rpath/libcurl.4.dylib
  Referenced from: /opt/vagrant/embedded/bin/curl
  Reason: Incompatible library version: curl requires version 9.0.0 or later, but libcurl.4.dylib provides version 7.0.0
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
DEBUG subprocess: Exit status: 5
 WARN downloader: Downloader exit code: 5
ERROR downloader: Exit code: 5

...


/opt/vagrant/embedded/gems/gems/vagrant-1.8.7/plugins/commands/box/command/add.rb:78:in `execute'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.7/plugins/commands/box/command/root.rb:61:in `execute'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.7/lib/vagrant/cli.rb:42:in `execute'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.7/lib/vagrant/environment.rb:308:in `cli'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.7/bin/vagrant:189:in `<main>'
 INFO interface: error: An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.


An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.


 INFO interface: Machine: error-exit ["Vagrant::Errors::DownloaderError", "An error occurred while downloading the remote file. The error\nmessage, if any, is reproduced below. Please fix this error and try\nagain.\n\n"]

ということで、

incompatible library version: curl requires version 9.0.0 or later, but libcurl.4.dylib provides version 7.0.0

curlの互換性の問題っぽい。

github.com

↑を参考にして、回避策が議論されていたので。以下を実行。

sudo ln -nsf /usr/bin/curl /opt/vagrant/embedded/bin/curl

そして、再度 vagrant box add package.box --name <box名> を実行。

...

 INFO interface: success: Successfully added box 'centos67_lamp' (v0) for 'virtualbox'!
 INFO interface: success: ==> box: Successfully added box 'centos67_lamp' (v0) for 'virtualbox'!
==> box: Successfully added box 'centos67_lamp' (v0) for 'virtualbox'!
 INFO warden: Calling OUT action: #<Vagrant::Action::Builtin::BoxAdd:0x000001020752d0>
 INFO environment: Running hook: environment_unload
 INFO runner: Preparing hooks for middleware sequence...
 INFO runner: 1 hooks defined.
 INFO runner: Running action: environment_unload #<Vagrant::Action::Builder:0x0000010329f050>

ということで無事に、vagrant box addが成功しました。

めでたしめでたし(・∀・)イイネ!!