LoginSignup
13
15

More than 5 years have passed since last update.

低スペWindowsでvagrantを導入するときに初心者がつまずきやすい2点

Last updated at Posted at 2016-03-09

色々な人にVagrantの使い方を教えていたら、なかなか躓くところが多いと感じたのでまとめておく。

そもそもvagrant init できない

windowsのユーザー名(正確にいえばユーザーディレクトリ)が日本語を含む場合、vagrantコマンドが失敗する。

C:\Users\太郎\Desktop\work\vagrant>vagrant init
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant.rb:59:in `requ
ire': cannot load such file -- childprocess (LoadError)
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant.r
b:59:in `<top (required)>'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/bin/vagrant:1
05:in `require'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/bin/vagrant:1
05:in `<main>'

日本語を含まないユーザーを作成し、そちらで作業するべし。

vagrant upでタイムアウトして終了する

==> 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 timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

単純にマシンスペックが足りず、VirtualBox側で起動に時間がかかり、起動しないケースもあったが、基本的には仮想化支援機構が有効になっていない場合もある。
Vagrantfileを下記のように編集して、virtualboxがGUIで立ち上がるようにする。

   config.vm.provider :virtualbox do |vb|
     # Don't boot with headless mode
     vb.gui = true
     # Use VBoxManage to customize the VM. For example to change memory:
     # vb.customize ["modifyvm", :id, "--memory", "1024"]
   end

しばらく待って、

仮想化支援機構(VT-x/AMD-V)を有効化できません。64ビットゲストOSは64ビットCPUを検出できず、起動できません。
ホストマシンのBIOS設定でVT-x/AMD-V を有効化してください。

このようなメッセージが出ることを確かめる。
これが出る場合、BIOSの設定を変更して、仮想化支援機構を有効にしよう。
BIOS設定を変更する

仮想化支援機構を有効にできない場合

古めのPCなどだと、仮想化支援機構を利用できないこともある。
仮想化支援機構を利用できないとゲストOSに64bitOSを使用できないので、32bitOSを使用することになる。
そんな人のためにvagrant up一発でrailsの環境が立ち上がるVagrantfileを書きました→Saxtondrey/rails_dev32
が、32bit環境ではメモリが4GBまでしか使用できなかったり、そもそも古いPCでは開発ば不便だと思いますので、おとなしく新しいPCを買いましょう。

13
15
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
13
15