Windows Users: cmd vs. cygwin (babun) vs. virtual machine

As a Windows user, I feel like I’m always dealing with issues that present themselves as a result of not being on a POSIX based operating system.

Tools like Git and Node (and programming languages like Ruby and Python) of course have their own Windows versions, but I feel they are truly second class citizens. You are guaranteed to run into an issue or limitation here or there.

I’ve managed to work my way around pretty much all of these issues, but now as I enter into a realm of dumping WAMP and using virtual machines for development (meaning Trellis, which requires VirtualBox and Vagrant), there becomes a careful balancing act of how you must manage your developer tools as a Windows user.

After a lot of thought and tinkering, I’ve come to conclude the following:

1) Avoid cygwin

Although something cygwin (Babun) seems like a nice choice, I feel it’s probably more trouble than it’s worth. There is a cognitive dissonance I must carry when being in the environment it provides.

  • I find that how it maps a Unix-like directory structure into your Windows directory structure to be well done but can get confusing especially when switching to a real Unix-like environment.
  • You can launch Windows programs from Babun (like notepad), but if there is a program that is both a Windows and Babun-installed program, this can quickly lead to confusion. For example, Git can come from both Windows and from Babun, so this can be very troublesome as well.

2) Use Window’s cmd.exe, but ONLY for managing vagrant.

vagrant up, vagrant halt, vagrant destroy, etc. Just cd into the project directory and run vagrant only. VirtualBox and Vagrant run without too many issues on Windows.

Make sure not to run cmd.exe as Administrator. Of course, you’ll need to make sure vagrant’s hosts updater correctly updates your Windows hosts file which is a protected file.

3) Create a dedicated Linux “command box” machine (this is the key point)

Since we’re avoiding cygwin altogether and only using cmd.exe to run Vagrant, we need a reliable environment to be able to run things like Git, Ansible and other general file management utilities.

I think having a dedicated virtual “command box” virtual machine that’s (a) ALWAYS running and automatically runs on boot (b) I’m always SSH’ed into using Putty and (c) is has access to my “Projects” directory via shared folders is the way to go.

From this command box machine, I’d go do my git commits from within my specific project directory (ie: /vagrant/Projects/project-x/).

From this command box machine, I can also SSH into my other projects, each of which have their own VM’s (make sure SSH keys are setup correctly). Alternatively, I could open a new Putty window and connect from there. It’s just a matter of personal preference.

4) Each project has it’s own VM

As is best practice, each project should have it’s own VM. Pretty much all Trellis at this point.

Workflow / putting for putting it all together with a new project, like (use your paths accordingly):

Inside “Command Box” (assuming you’re already SSH’ed into it)

cd /vagrant/Projects/
git clone

Inside cmd.exe

cd c:\Users\jlahijani\Projects\\
vagrant up

Inside “Command Box”

ssh vagrant@your-trellis-box-ip-address -p the-port-number

Now that you are SSH’ed into the Trellis Project box, go to the theme dir and run npm install, bower install, gulp watch, etc.

I’d like to hear any thoughts on this.


Inside “Command Box”

ssh vagrant@your-trellis-box-ip-address -p the-port-number

How do you get the route from Command VM to host only connected virtualbox VM?
My project vms have host only adapters with IP address.

Personally I’ve become a big fan of the Laravel Homestead pre-packaged Vagrant box. It comes with everything for PHP & Laravel development with good documentation.

One issue I’ve found with using VM’s though is the lack of local language tool support. In the case of PHP for example if its on a VM I can’t have a local copy of PHP Codesniffer or a CLI php to lint files which are used by my favourite editors (Sublime Text 3 & Atom). So you miss out on some nice editor/IDE features going solely the VM route.

I’ve got a bit of a mish-mash now then which works pretty well.

A Homestead Vagrant box for web serving, Git, other Linux tools, etc.
Then I have basic installs of PHP, phpcs, php-cs-fixer and base Python on the host Windows OS for editor integrations.

No extraneous XAMP/WAMP setups and you get the best of both worlds then. :thumbsup:

P.S. not heard of Trellis. I Googled and the only thing I can think you’re reffering to is a Wordpress Ansible playbook - is that right?

P.P.S I went to the homepage. Now I feel stupid asking what Trellis is! :blush:

I wrote this article there is explained step by step how to install trellis on windows quicky. I don’t use keys, but credentials to login into vagrant.