あーる学習帳

自分が勉強したことや気になることなど、99%自分用です。コードを書いてるのでPCから閲覧を推奨。

仮想環境構築②

ゲームは一日一時間(体感)。

 

昨日の続きで仮想環境構築。ドットインストールの動画を見直したところ、

Vagrant 1.8.6 ・VirtualBox 5.1.8

を使っているのでそれに合わせてみる。

どちらもリリースが2年前くらい。

Hyper-V無効化の状態(立ち上げ時に「Disable Hyper-V」を選択)で起動し、

VirtualBoxVagrantの順にインストールした後に環境構築のコマンドを実行。

 

今回は仮想マシン設定用のVagrantFileを作るところでエラー。

Bundler, the underlying system used to manage Vagrant plugins,
is reporting that a plugin or its dependency can't be found.
This is usually caused by manual tampering with the 'plugins.json'
file in the Vagrant home directory. To fix this error, please
remove that file and reinstall all your plugins using `vagrant
plugin install`.
C:/HashiCorp/Vagrant/embedded/gems/gems/bundler-1.12.5/lib/bundler/resolver.rb:356:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'vagrant-vbguest x86-mingw32' in any of the gem sources listed in your Gemfile or available on this machine. (Bundler::GemNotFound)
from C:/HashiCorp/Vagrant/embedded/gems/gems/bundler-1.12.5/lib/bundler/resolver.rb:331:in `each'
from C:/HashiCorp/Vagrant/embedded/gems/gems/bundler-1.12.5/lib/bundler/resolver.rb:331:in `verify_gemfile_dependencies_are_found!'
from C:/HashiCorp/Vagrant/embedded/gems/gems/bundler-1.12.5/lib/bundler/resolver.rb:200:in `start'
from C:/HashiCorp/Vagrant/embedded/gems/gems/bundler-1.12.5/lib/bundler/resolver.rb:184:in `resolve'
from C:/HashiCorp/Vagrant/embedded/gems/gems/bundler-1.12.5/lib/bundler/definition.rb:200:in `resolve'
from C:/HashiCorp/Vagrant/embedded/gems/gems/bundler-1.12.5/lib/bundler/definition.rb:140:in `specs'
from C:/HashiCorp/Vagrant/embedded/gems/gems/bundler-1.12.5/lib/bundler/definition.rb:185:in `specs_for'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant.rb:76:in `<top (required)>'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/bin/vagrant:105:in `<main>' 

C:\HashiCorp\Vagrant\embedded\plugins.json

というやつが悪さをしているようなので消してしまえ!というエラーらしい。

そいつを消してvagrant plugin installを実行したらまた同じエラー。

vagrant plugin install vagrant-vbguestだったり、

vagrant plugin expunge --reinstallもやってみたが、

実行したvagrantのコマンド全部で同じエラーが出ている。

インストールの段階で何か失敗しているっぽい?

Hyper-Vを有効にした状態(=通常のWIndows10)で起動し、再インストールしてみる。

やはりvagrant init bento/centos-6.8を実行すると上記のエラーが発生。

だんだん悲しくなってきたぞ…。

Windows10 のバージョン1709だとこの方法は難しい?

 

こちらに載っていた環境変数の設定を試してみることにする。

Windows 10にVirtualBoxとVagrantでCentOSの仮想環境を作ってみた

VirtualBoxVagrant共に最新版をインストールしたところ、

Vagrantプラグインのインストールを要求されたが

Vagrant Upまでこぎつけることができた。

そこでHyper-Vの設定が今の状態だとダメだと言われたので

Disable Hyper-Vの状態になるよう再起動。

ドキドキしながらVagrant Upを実行すると…

Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

mount -t vboxsf -o uid=500,gid=500 vagrant /vagrant

The error output from the command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

 なんか昨日見たぞ。仮想マシンは起動してるけど共有ができないやつ。

「/sbin/mount.vboxsf: mounting failed with the error: No such device」で検索すると結構な数の事例が出てくる。

ホストとゲスト間のフォルダ共有機能について、機能のバージョンが不一致していることが原因なのでプラグインを入れてみる。ダメでした。

ドットインストールに従うなら、「レッスンでは共有使わないから問題ないぜ!」とのことなのでもう無視して先に進めます。埒が明かないので。

 

お待ちかねのVagrant Statusを実行すると…

Current machine states:

default running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.

現在実行されているとのこと。やったぜ。

 

続いて、PuTTYをインストール。

putty-64bit-0.70-installer.msiをダウンロードして実行。

その後PuTTY仮想マシンにログイン。パスワードは入力しても*とか出ないので注意。

このままでは仮想マシンが空っぽなので、以下のコマンドで中身を入れていく。

ドットインストールの内容をそのままコピペ。

# OSを最新状態にアップデート(めっちゃ時間かかる)
sudo yum -y update

# スクリプトを入手するためのgitをインストール
sudo yum -y install git

# gitを使ってアプリケーション設定用のスクリプトをダウンロード
git clone https://github.com/dotinstallres/centos6.git

# centos6フォルダができるのでそちらに移動
cd centos6

# スクリプトを実行(めちゃめちゃ時間かかる)
./run.sh

# もろもろの設定を反映
exec $SHELL -l

今夜は遅いのでここまで。

PuTTYのコマンドを実行している間にだいぶ時間があったので、寝る時間を惜しんでやるのはおすすめできないかも。