Since I'm starting a new job soon, I had to hand in my work laptop (a MacBook) and was forced to confront a chilling reality: I'll need to develop on my home PC.
Now, I've already created a separate partition running Ubuntu 17.04, but I was quickly growing tired of rebooting when I just wanted to tinker around with a little bit with React, GraphQL and Flask.
So, I thought to myself, how hard would it be to get a sensible development environment running inside Windows? Turns out there are a few challenges.
First, let's list some of the criteria I have:
- A slick command line interface
- A performant browser/GUI experience (meaning, no lag)
- All the goodness that a Unix-based OS allows (bash, apt-get, git from command line, zsh, npm/node without all the Windows hassles, etc)
Seems totally reasonable, right? Anyways, I tried a number of different things, with varying degrees of success. Let's run through it.
Option #1: Ubuntu Bash for Windows
- Easy to set up
- Single executable
- Finding the Ubuntu file space is unnecessarily cryptic. Protip: it's in
- Getting bidirectional file read-write between Windows and Ubuntu is basically asking for trouble. You'll get all of the criteria above, except for actually manipulating files using an IDE etc - which is, of course, a deal breaker.
Option #2: Ubuntu Desktop as Guest OS in VirtualBox
- The entire Ubuntu Desktop, inside Windows.
- It's great for writing code (vim, Webstorm, VSCode and Sublime Text all work really well).
- Since we're running an embedded OS, resource-intensive operations - especially animations /transitions within the browser - are really chunky. Even with hardware acceleration and graciously allocated VM resources, you'll experience laggy performance when running anything visually taxing.
Option #3: SSH into Ubuntu Server running in VirtualBox
After considerable effort, I've found this one to work the best for my workflow: just install Ubuntu Server (or Desktop, if you want) and SSH directly into the box. To get access to project files that you're working on, you just set up a shared drive between the two operating systems.
Here's a breakdown on how to get it working:
- Download the latest Ubuntu Server image here.
- Install the VirtualBox image.
- Set up port network adapter to Bridged Adapter. To do this: go to Settings > Network > Adapter. Optionally, you can set it to NAT and configure Port Forwarding using the following settings:
|Name||Protocol||Host IP||Host Port||Guest IP||Guest Port|
- Get the VM's local IP address for SSH. To do this, log into your VirtualBox machine as you would normally and run
ifconfig. You should get something like this:
Next, download Putty (or an equivalent SSH client), start it up and connect via SSH to
Now, set up a shared drive between the host and the guest OS. To do this, go to
Settings > Shared Folders. Take note of the name of this directory, because you'll need to mount this directory in Ubuntu.
To mount the directory, log into the Ubuntu VM and run
sudo mount -t vboxsf -t YOUR_DIRECTORY_NAME ~/YOUR_DIRECTORY_NAME. If you encounter an error (
mount.vboxsf: mounting failed with the error: No such deviceetc), then you need to install Guest Additions. The easiest way to do this is to run:
sudo apt-get install virtualbox-guest-x11. There's also a dropdown option in the VirtualBox GUI, but I've found that it's a little buggy.
With all of this done, you should have a shared directory between Ubuntu and Windows! The best of both worlds™.
Please note: There's a known problem/security concern with symlinks when running a virtual operating system in VirtualBox. Why is this a problem? Well, if you run any script that involves linking a binary to your global path (think:
npm install somelib -g), then this will just straight up fail. To work around this, follow these configuration steps:
1) Open Command Prompt and navigate to:
2) Run the following:
VBoxManage YOUR_VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOUR_DIRECTORY_NAME
3) Start VirtualBox again, but be sure to Run as Administrator. Login via SSH, re-run your script(s) - everything should work now!