9

I'm trying to change my VagrantFile so that it uses an NFS mount instead of the default VirtualBox shared folders.

I get this error message:

vm:
* Shared folders that have NFS enabled do not support owner/group
attributes. Host path: .

This is my VagrantFile:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 
  config.vm.box = "ktbartholomew/lamp"
  config.vm.network "private_network", type: "dhcp"
  config.vm.synced_folder ".", "/vagrant", type: "nfs"
end

I can't see any owner or group getting set.

Please help! Thanks

JamesPlayer
  • 1,834
  • 2
  • 15
  • 21
  • Have you tried using something other than '.' for the source folder to mount from host? It seems like that might be your problem. try defining it with a full path. Like '/home/user/project' or what ever your path is. The rest of your statement looks just like what I currently use. – noeldiaz Jul 26 '14 at 03:43
  • I just changed it and unfortunately same problem, although now the error message is "* Shared folders that have NFS enabled do not support owner/group attributes. Host path: /Users/jamesplayer/Sites/" – JamesPlayer Jul 28 '14 at 17:18

2 Answers2

3

I've found mapping the uid/gid directly works OK. It's a little weird on the vagrant side, because they are arbitrary users/groups but apart from that it is fine.

Vagrant.configure("2") do |config|
  # ...
  config.nfs.map_uid = Process.uid
  config.nfs.map_gid = Process.gid
  config.vm.synced_folder ".",  "/vagrant", id: "vagrant-root", :nfs => true
  config.vm.synced_folder "..", "/var/www", id: "application",  :nfs => true
end
Ryan
  • 4,594
  • 1
  • 32
  • 35
2

Vagrant only raises this error when the owner or group is true. Try forcing it by passing nil for both these options for both synced_folder configs.

, group: nil, owner: nil

Here's the code: https://github.com/mitchellh/vagrant/blob/8655d212c327d363f8e80185705ff70bb2e97f6b/plugins/kernel_v2/config/vm.rb#L572

Bijan
  • 6,675
  • 6
  • 33
  • 29
  • Thanks! This is what my final VagrantFile ended up looking like: VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ktbartholomew/lamp" config.vm.network :private_network, ip: "10.11.12.13" config.vm.synced_folder "/Users/jamesplayer/Sites/", "/vagrant", type: "nfs", group: nil, owner: nil end – JamesPlayer Sep 15 '14 at 22:57
  • Basically do not use group, owner, mount_options as attributes – Kim Stacks Dec 24 '14 at 13:25
  • Vagrant only raises this error when the owner or group _is_ true (and nfs is set) – Lotus Jul 15 '15 at 19:01
  • Thanks Lotus, fixed the wording. – Bijan Jul 23 '15 at 19:20