LoginSignup
20
16

More than 5 years have passed since last update.

Windows+VagrantでCentOS7の公式boxが起動できない("rsync" could not be found on your PATH)

Last updated at Posted at 2016-11-06

TL;DR

vagrant-vbguestをインストール(vagrant plugin install vagrant-vbguest)して、Vagrantfileをconfig.vm.synced_folder ".", "/vagrant", type: "virtualbox"に書き換える。

背景

 WindowsのVagrantでCentOS7のbox(centos/7)を入れようとしたが、vagrant upに失敗する。

コマンドプロンプト
C:\Users\tenmyo\vm\test>vagrant init centos/7
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.

C:\Users\tenmyo\vm\test>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' is up to date...
==> default: Setting the name of the VM: test_default_1478419157855_72559
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
"rsync" could not be found on your PATH. Make sure that rsync
is properly installed on your system and available on the PATH.

調査

関連Qiita記事

Windows 7 + Vagrant 1.4.2 でCentOS7のboxが起動できなかったので調べた - Qiita
Windows環境のVagrantでCentOS Atomic Hostを動かす - Qiita

2016/11/15 こちらの記事でばっちり解説されていました。

vagrant において、明示的に VirtualBox の機能(vboxsf)を使いフォルダを同期するには、config.vm.synced_folder ".", "/vagrant", type: "virtualbox" のように Vagrantfile に設定するとよい - Qiita

原因

 boxのVagrantfileで config.vm.synced_folder ".", "/vagrant", type: "rsync" と共有フォルダ種類を rsync 決め打ちにされていて、 Windows は rsync が入っていないためエラーとなっている。
CentOS公式BoxはVirtualBoxの共有フォルダ(Guest Additions)をあえて無効にしているみたい。公式リリースノート

対処

 下記の方法がある。自分は手軽で便利な3にした。

  1. 共有フォルダを無効にする
  2. rsync をインストールする
  3. 共有フォルダ種類を Vagrant デフォルトに再設定する

共有フォルダを無効にする

 関連Qiita記事で上がっている方法。 Vagrant ファイルを以下のようにdisabled: trueする。

Vagrantfile
Vagrant.configure(2) do |config|
  config.vm.synced_folder ".", "/vagrant", disabled: true
end

rsync をインストールする

 まっとうな方法

共有フォルダ種類を Vagrant デフォルトに再設定する

Vagrant ファイルを以下のようにtype: nilする。

2016/11/15追記:type:"virtualbox"でもよいようです。

Vagrantfile
Vagrant.configure(2) do |config|
  config.vm.synced_folder ".", "/vagrant", type:nil
end
20
16
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
20
16