For our developers ~/Development/framework_repo
is normally available on the host, but for our designers it wouldn't be. Is it possible to conditionally configure a synced folder depending on it's availability on the host?
NFS is a faster way of sharing your project's files between host and guests that sync the files instantly. To use NFS with Vagrant, nfs-utils package needs to be installed and nfs-server needs to be running. If it is not, run: $ sudo dnf install nfs-utils && sudo systemctl enable nfs-server.
Using SCP. Another way to copy files and folders from host to guest in Vagrant is to use to SCP. Firstly, make sure you have scp installed on your host. If you don't have it, you can install the openssh-clients package if you're using Linux or install Cygwin if you're using Windows.
Since the Vagrantfile is a Ruby script, you could check for the presence of the directory with File.directory()
, and enable the shared folder only if needed.
For example:
Vagrant.configure("2") do |config|
if File.directory?(File.expand_path("~/Development/framework_repo"))
config.vm.synced_folder "~/Development/framework_repo", "/guest/path"
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With