If share_folder doesn't exist, create it #604

Closed
dkingofpa opened this Issue Dec 21, 2011 · 4 comments

Comments

Projects
None yet
3 participants

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")
Owner

mitchellh commented Jan 8, 2012

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.

@mitchellh mitchellh closed this Jan 8, 2012

That'll do. Thanks Mitchell!

haydenk commented May 1, 2013

What about?

vm:
* The following settings don't exist: share_folder
Owner

mitchellh commented May 1, 2013

@haydenk You're probably using V2 config syntax, share_folder is from V1: http://docs.vagrantup.com/v2/vagrantfile/version.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment