1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

vagrant init, vagrant up時のプラグインによるエラー

Last updated at Posted at 2020-05-13

#The Plugin failed
久しく使ってなかったMBPを開いてvagrant initするとエラーが起こった。

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 'sahara (> 0)'

なんかVagrantのホームディレクトリでプラグインが弄られてて、そのプラグインが駄目らしいです。
最後にしれっとエラーメッセージが書いてあって、うちの場合saharaっていうプラグインが依存関係になってるのが原因でした。
vagrant up時も同じようなエラーが出る模様。

#vagrant plugin repair

Vagrant can attempt to automatically correct this issue by running:

vagrant plugin repair

ということで、まずはvagrant plugin repairというコマンドを打ち込んで自動修正を試してほしいとのこと。

$ vagrant plugin repair
Repairing currently installed global plugins. This may take a few minutes...

#...

Failed to automatically repair installed Vagrant plugins. To fix this
problem remove all user installed plugins and reinstall. Vagrant can
do this for you automatically by running the following command:

  vagrant plugin expunge --reinstall

Failure message received during repair:

Unable to resolve dependency: user requested 'sahara (> 0)'

おやおや、修正できないから全部インストールし直してくれってことですね。
reinstallはvagrant plugin expunge --reinstallというコマンドでやれと。

#vagrant plugin expunge --reinstall

$ vagrant plugin expunge --reinstall

This command permanently deletes all currently installed user plugins. It
should only be used when a repair command is unable to properly fix the
system.

Continue? [N]: y

最初に「このコマンドお前の持ってるプラグイン全部消すで?再インストールするつもりやで。もしかするとよそで問題起きるかもしらんけどほんまにええか?」と念押ししてきます。Continue? [N]:とYを用意してないけど気にせずyで進めた。

All user installed plugins have been removed from this Vagrant environment!

Vagrant will now attempt to reinstall user plugins that were removed.
Installing the 'sahara' plugin. This can take a few minutes...

#...

Installed the plugin 'sahara (0.0.17)'!
Installing the 'vagrant-hostsupdater' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostsupdater (1.1.1.160)'!
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.24.0)'!
Installing the 'vagrant-vbox-snapshot' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbox-snapshot (0.0.10)'!

無事問題のあるプラグインをreinstallしたようです。vagrant-hostsupdaterとか他にも諸々出てきました。

#vagrant plugin update
Vagrantに入ってるプラグイン全部インストールし直さなくても、コマンドvagrant plugin update saharaで名指しされてるsaharaをアップデートしてしまえばそれでよかったのでは?と一瞬思った。でもsaharaが解決しても次にまたvagrant-hostsupdater…と同じ対処を繰り返さなければならなかったはずなので、こういうときはとりあえずreinstallしとけってことっすな。

#無事直った。
その後vagrant initしてみると

$ vagrant init
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

ちゃんとinitializeしてくれたぜ。めでたし。

#参考
【Vagrant】vagrant upするとエラーが発生するようになったので修正しました、という軌跡 - Qiita

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?