36

Is it possible to set more than one sync'd folder in a vagrantfile? Here's my current config (using vaprobash):

# Use NFS for the shared folder
config.vm.synced_folder ".", "/vagrant/Sites",
          id: "core",
          :nfs => true,
          :mount_options => ['nolock,vers=3,udp,noatime']

# Use NFS for the shared folder
config.vm.synced_folder "../Code", "/vagrant/Code",
          id: "core",
          :nfs => true,
          :mount_options => ['nolock,vers=3,udp,noatime']

Only the second mapping gets loaded, the other is ignored-- so I end up with a /vagrant/Code directory mapped properly, but no vagrant/Sites

1 Answer 1

63

2021 Update:

In 2021 no need for unique Id or being nfs, just list your synced folders:

config.vm.synced_folder ".", "/vagrant/Sites"
config.vm.synced_folder "../Code", "/vagrant/Code"

Original answer:

I just needed to set a unique ID for each mount, and then reload the vagrant box.

# Use NFS for the shared folder
config.vm.synced_folder ".", "/vagrant/Sites",
      id: "sites", # <--- this ID must be unique
      :nfs => true,
      :mount_options => ['nolock,vers=3,udp,noatime']

# Use NFS for the shared folder
config.vm.synced_folder "../Code", "/vagrant/Code",
      id: "code", # <--- different from this one
      :nfs => true,
      :mount_options => ['nolock,vers=3,udp,noatime']

Not the answer you're looking for? Browse other questions tagged or ask your own question.