mitchellh/vagrant — Issue #604: If share_folder doesn't exist, create it
Author: dkingofpa
Created: 2011-12-21 19:41:38+00:00
State: open

When I specify a share_folder in my vagrantfile like so

config.vm.share_folder("www", "/vagrant/www", "./www", :owner => "www-data", :group => "www-data")

vagrant will error out:

dking@desktop78 ~/projects/vagrant-librarian $ vagrant up
There was a problem with the configuration of Vagrant. The error message(s)
are printed below:

vm:
* Shared folder host path for 'www' doesn't exist: ./www

I would like to see vagrant just create the missing host path. Committing an empty folder with a placeholder file into my git repo isn't the answer. In the mean time, this is how I'm working around the limitation in my vagrantfile:

if not FileTest::directory?("./www")
Dir::mkdir("./www")
end
config.vm.share_folder("www", "/vagrant/www", "./www", :owner => "www-data", :group => "www-data")