Vagrantのpluginをインストールしようとして、nokogiriのエラーになる場合

Vagrantのpluginをインストール

 Vagrantのpluginを入れようとして、nokogiriがないとエラーになりました。

$ vagrant plugin install vagrant-digitalocean
Installing the 'vagrant-digitalocean' plugin. This can take a few minutes...
Building nokogiri using packaged libraries.
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.3.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.3.1'` succeeds before bundling.

対処方法としては、どうやらnokogiriの1.6.2.1が既に入っているので、それを使うように指定するとうまく動きました。

$ sudo vim /Applications/Vagrant/embedded/gems/specifications/vagrant-1.6.3.gemspec 

次の1行を適当に追加

  s.add_dependency(%q, ["= 1.6.2.1"])

やり方は、githubのissuesに書いてありました。

その結果

pluginを入れ直した結果、Digital OceanのAPIがv2.0にバージョンアップしたようで、以前動作していたVagrantfileでは動作しなくなってました。

$ vagrant ssh
There are errors in the configuration of this machine. Please fix
the following errors and try again:

Digital Ocean Provider:
 * Token is required

Digital Oceanの設定ページhttps://cloud.digitalocean.com/settings/applicationsで、Personal Access Tokensの欄でGenerateしたtokenをVagrantfileに書くとうまく動きました。以前まで使っていたclient_idとapi_keyは使わなくてもOKでした。

$ vim Vagrantfile 
 ...
#    provider.client_id = 'YOUR_CLIENT_ID'
#    provider.api_key = 'YOUR_API_KEY'
    provider.token = 'YOUR_NEW_GENERATED_TOKEN'
 ...

世の中のサービスはどんどんバージョンアップしていきますねぇ。