mk-toolブログ

エンジニアと家のことをごちゃごちゃと書いてます

【vagrant】vagrant upの際にIPが衝突とかよく分からないことを言われた話

 

>||

The specified host network collides with a non-hostonly network!
This will cause your specified IP to be inaccessible. Please change
the IP or name of your host only network so that it no longer matches that of
a bridged or non-hostonly network.

||<

 

IPが衝突?よくわからない、というのが感想です。とりあえず解決だけはできたので、解決策をメモします。どうして解決できたか具体的な理由までは、分かっておりません。

以下のコマンドを実行すると、「イーサネット アダプター VirtualBox Host-Only Network #5:」という欄があります。そのIPアドレスを覚えておきます。

>||

ipconfig

||<

 

ここで、仮想マシンを起動する際に、接続先IPを設定しているファイル(私はLaravelのHomestead.yamlというファイルが該当しました)を開いて、接続先IPに先の「ipconfig」の結果のIPを設定します。

>|php|

#ip: "192.168.10.10" これはコメントアウトして、下の行に変更後のIPを書きます
ip: "192.168.33.1"

||<

これで「vagrant up」が通るようになりました。

【vagrant】vagrant upの際にrbファイルが影響して立ち上げられないことに対する対応

vagrant up」と入力したものの、以下のエラーが出てしまった。

C:\Users\ユーザ名\MyVagrant\mycentos\Homestead>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/provisioners/shell/config.rb:62:in `expand_path': incompatible character encodings: UTF-8 and Windows-31J
(Encoding::CompatibilityError)
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/provisioners/shell/config.rb:62:in `expand_path'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/provisioners/shell/config.rb:62:in `validate'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/kernel_v2/config/vm.rb:739:in `block in validate'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/kernel_v2/config/vm.rb:729:in `each'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/kernel_v2/config/vm.rb:729:in `validate'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/config/v2/root.rb:68:in `block in validate'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/config/v2/root.rb:64:in `each'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/config/v2/root.rb:64:in `validate'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/builtin/config_validate.rb:15:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:225:in `action_raw'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:200:in `block in action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/environment.rb:561:in `lock'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:186:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:186:in `action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'

rbファイルとか、文字コードとか全然わけわかんない!状態に陥りましたが、実はこれ、パス名の中に日本語が入っていることが原因でした。
ユーザのフォルダ名が日本表記から英語表記に変更すればOKです。といっても、変更の仕方がわからないので、ユーザを新しく追加をして
新しいユーザで作業をしています。

【vagrant】vagrant upで仮想マシンが立ち上がらなかったのでメモ

windows10環境で

vagrant up

が立ち上がらなかった。

その際に出てきたメッセージは以下。

The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' state. Please verify everything is configured
properly and try again.

If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.

The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.

エラーはGUIから詳細を確認してね、とのことですが、確認せずに解決策だけ書きます。

VirtualBoxを入れなおします。と言っても、既にVirtualBoxを入れている方でも既存のVirtualBoxをアンインストールせずに入れても問題ありません(少なくとも私は問題ありませんでした)。この際、入れるものに注意が必要で、VM VirtualBox Extension Packを入れる必要がありました。私もそうでしたが、VirtualBoxどれを入れればいいのかな、ダウンロードページの一番上にあるのが無難かな、と思ってダウンロードした方はおそらくExtension Packではないです。ダウンロード用のサイトは以下です。
Downloads – Oracle VM VirtualBox

後は、下記のように起動するだけです。
(私の場合、なぜか一度目の「vagrant up」はタイムアウトになってしまいます。しかし、もう一度「vagrant up」を実行するとタイムアウトは起きずに「running」状態になります。まぁ動いたからいいか…。「vagrant status」で状況を逐一確認してください。)

del VagrantFile
vagrant box list
vagrant init box名
vagrant up
vagrant status

あまり関係ないけど、以下のサイトは読んでみると楽しそうなのでメモ。
www.kaasan.info