vagrant box updateしたら立ち上がらない

  プログラミング, 未分類

サマリー

vagrant upしたらvagrant box updateしろと表示されたので素直に従ったら動かなくなったところからの、動きました

初期症状

いつもどおり、vagrant upしようとしたら、

% vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/bionic64' version '20181129.0.0' is up to date...
==> default: A newer version of the box 'ubuntu/bionic64' for provider 'virtualbox' is
==> default: available! You currently have version '20181129.0.0'. The latest is version
==> default: '20201211.1.0'. Run `vagrant box update` to update.
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

version ‘20181129.0.0’が最新かどうかを確認したけど、新しい’20201211.1.0’があるから`vagrant box update`を実行したら?みたいなことを言われました。

素直にvagrant box updateしてみた

ワーニングが出ても立ち上がってるんだから、放っておけばよかったじゃない、とは言わないで・・・

% vagrant box update
==> default: Checking for updates to 'ubuntu/bionic64'
    default: Latest installed version: 20181129.0.0
    default: Version constraints:
    default: Provider: virtualbox
==> default: Updating 'ubuntu/bionic64' with provider 'virtualbox' from version
==> default: '20181129.0.0' to '20201211.1.0'...
==> default: Loading metadata for box 'https://vagrantcloud.com/ubuntu/bionic64'
==> default: Adding box 'ubuntu/bionic64' (v20201211.1.0) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/ubuntu/boxes/bionic64/versions/20201211.1.0/providers/virtualbox.box
Download redirected to host: cloud-images.ubuntu.com
==> default: Successfully added box 'ubuntu/bionic64' (v20201211.1.0) for 'virtualbox'!

Successfully added box ‘ubuntu/bionic64’ (v20201211.1.0) for ‘virtualbox’! = 成功した!と喜び、

再度 vagrant up

% vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/bionic64' version '20181129.0.0' is up to date...
==> default: A newer version of the box 'ubuntu/bionic64' is available and already
==> default: installed, but your Vagrant machine is running against
==> default: version '20181129.0.0'. To update to version '20201211.1.0',
==> default: destroy and recreate your machine.
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 8000 (guest) => 8000 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 5.2.34
    default: VirtualBox Version: 6.1
==> default: Mounting shared folders...
    default: /vagrant => /Users/admin/vagrant/ubuntu64_18
    default: /home/vagrant/workspace => /Users/admin/vagrant/ubuntu64_18/workspace
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

最新バージョンがインストールしてあるのに、お前は古いほうを起動している、みたいなことを言われました

バージョンをいい感じにしてくれるコマンド

Google先生曰く、複数入ってしまったバージョンをいい感じにしてくるらしいコマンド、vagrant box prune を実行。「古いほう消すよ?」と言われて「y(es)」

ところで「y(es)」って、「り(ょうかい)」みたいですね。

% vagrant box prune
The following boxes will be kept...
ubuntu/bionic64 (virtualbox, 20201211.1.0)

Checking for older boxes...
Box 'ubuntu/bionic64' (v20181129.0.0) with provider 'virtualbox' appears
to still be in use by at least one Vagrant environment. Removing
the box could corrupt the environment. We recommend destroying
these environments first:

default (ID: f5e984af9ecb4d0d81203fe519405590)

Are you sure you want to remove this box? [y/N] y
Removing box 'ubuntu/bionic64' (v20181129.0.0) with provider 'virtualbox'...

本当にいい感じになったのかを確認

vagrant box listのコマンドで、最新の1つだけが表示されればOKだそうです。

% vagrant box list
ubuntu/bionic64 (virtualbox, 20201211.1.0)

無事起動できました

その後、vagrant up、vagrant sshができました