Shared folders in Vagrant

Posted

A few months ago we moved our development environment for Teamwork Projects to Vagrant. This move enabled us to speed up the setup process on a new machine from 8 hours to 30 minutes. Wouldn’t you know it, things didn’t work as smoothly as we expected. The following is a problem we came across and solved beautifully!

Vagrant boxes have access to a shared folder which stored on the host file system. The suggested sharing mechanisms are SMB, Rsync and NFS. We ended up having to try all of them for various reasons. SMB was far too slow, rsync wouldn’t work for us because our codebase needs to be run on a case insensitive (ci) file system and NFS isn’t supported by windows.

In comes WinNFSd. It’s an open source program that can share a folder via the NFS protocol on windows. Someone’s even created a Vagrant plugin for it! Perfect?

We found that WinNFSd had the same case issues as Rsync but this didn’t make much sense to us. An NFS server should follow the rules of the file system for serving files- it’s how SMB works and how NFS works on a mac. At this point we were reeling at the thought of having to go through the entire codebase changing every file name reference to lowercase.

It can’t end this way! So I had a look through the source of WinNFSd on bitbucket searching for any mention of case and found the following function call:

Changing strcmp to _strcmpi worked perfectly:

If anyone else has the same issue with WinNFSd, you can use our fork of the repo at: https://github.com/JaTochNietDan/vagrant-winnfsd.

PS: Props to Rob who actually forked & built the repo 🙂