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")
Okay. I didn't want to make creating a shared folder the default because a simple typo could cause unexpected results (a folder would be created and it would look empty on the VM, which would not be expected).
Instead, I opted to get shared folders another option, the :create flag. If this flag is set to true (false by default), then it will attempt to create the folder if it does not exist. For example:
config.vm.share_folder "www", "/vagrant/www", "./www", :create => true
Simple enough?
Pushed, will be part of next release.
That'll do. Thanks Mitchell!
What about?
vm:
* The following settings don't exist: share_folder
@haydenk You're probably using V2 config syntax, share_folder is from V1: http://docs.vagrantup.com/v2/vagrantfile/version.html
Most helpful comment
Okay. I didn't want to make creating a shared folder the default because a simple typo could cause unexpected results (a folder would be created and it would look empty on the VM, which would not be expected).
Instead, I opted to get shared folders another option, the
:createflag. If this flag is set totrue(falseby default), then it will attempt to create the folder if it does not exist. For example:Simple enough?
Pushed, will be part of next release.