At a previous job we were restricted to Windows PCs only. This made setting up certain development tools more annoying than it should be.
Recently I started using Vagrant and Chef which both come with native Windows MSIs, except using these would require using the Windows command shell. But with a few additional steps I was able to get these running under Cygwin using the native MSIs.
Download and install the native Windows installer
If you don’t have it already, install git under Cygwin. Use the Cygwin installer for this and select the ‘git’ package.
The main issue I ran into after this point was that Chef uses a version of Ruby native to Windows, which means that running the various Chef scripts under Cygwin fail since the native Ruby program doesn’t understand the Cygwin style paths. But this is easy enough to work around by creating a few aliases in your bash profile. Change the paths below to match wherever you installed Chef:
1 2 3 4
At this point you should be able to run
chef-client -vwithout any errors.
Next setup a repository for your cookbooks. I’d recommend just cloning the opscode repository:
- Finally configure knife
If you’re using Hosted Chef or Chef Server include your validation keys in
chef-repo/.chef/ as well.
Note: when running
knife cookbook site install X the process will fail to unzip the cookbook. However you can just manually unzip it to get it working.
If you don’t have it, get Virtualbox
Download and install the MSI installer for Vagrant
I had an issue running Vagrant out of the box due to some wonky line breaks so do this:
Vagrant defaults to creating Virtual Box VMs in Cygwin home and not Windows home. This will cause a problem if these are two seperate locations on your machine. After setting up a VM under Vagrant it will appear as if you’ve lost all VMs created outside of Vagrant.
You can fix this by creating a link in your Cygwin home before creating any Vagrant VMs. The links can be created through Windows command shell (but that’s as much as you’ll ever need to do in Windows shell for Vagrant/Chef). These commands should be run as administrator:
1 2 3
Or if you hate links you could just relocate your Cygwin home directory to match your Windows home directory. Or relocate your Virtualbox folders from your Windows home to Cygwin home.
You should now have a fully working Vagrant and Chef setup that can be invoked from Cygwin.