We need to share VMs with Linux, MacOS and Windows hosts. However, for Linux and MacOS, NFS sharing is recommended, but for Windows, NFS sharing is not supported.
Is there are way to detect the that host OS is Windows and disable NFS shares?
This has actually already been taking care of as of Vagrant 1.2.5, see Option for NFS is not silently ignored on windows hosts and the respective commit b2d1a26 (NFS request is silently ignored on Windows):
@__synced_folders.each do |id, options|
# Ignore NFS on Windows
if options[:nfs] && Vagrant::Util::Platform.windows?
options[:nfs] = false
end
end
If you aren't able to upgrade you might want to try Ryan Seekely's Vagrant and using NFS only on non Windows hosts:
Well, since a Vagrantfile is nothing but a Ruby script, we can just use Ruby! At the top of the Vagrantfile define:
def Kernel.is_windows? # Detect if we are running on Windows processor, platform, *rest = RUBY_PLATFORM.split("-") platform == 'mingw32' end
And then when configuring your shared folder:
nfs = !Kernel.is_windows? config.vm.share_folder "myfolder", "/srv/www/myfolder.com/", "../", :nfs => nfs
Please note that I haven't actually tested this particular solution, but have been using a conceptually similar approach myself before, albeit using Vagrant::Util::Platform.windows?
as in the official commit (don't have it handy right now ...).