The Windows command line is unpleasant to use and I want a fully functional Linux shell or VM to work with cloud-based technologies like Node. Vagrant allows me to work on Linux VMs from inside of Windows. It’s a more efficient workflow than using VirtualBox Manager alone. Unfortunately, Vagrant is still a bit rough to set up properly, especially with Meteor and MongoDB. Fortunately, it’s very usable in it’s current state and solves many of the limitations of using Linux Subsystem for Windows, Cygwin, and MINGW64.
Vagrant Problems with the Ubuntu Atlas
This site looks good, but it’s not.
Vagrants issues on GitHub has a great explanation by sethvargo, the director of evangelism at HashiCorp, the main company behind Vagrant.
the boxes published by canonical under the ubuntu namespace for 16.04 are very broken. They do not follow the recommended guides for how to build a Vagrant box, and they are missing key components such as guest additions, required packages, or they do things like hardcode the hostname to make running concurrent VMs impossible. There are bare minimum requirements for building base boxes with Vagrant, and that image is simply malformed.
In general, users have had more success with the boxes under the bento namespaces. A common misconception is that a namespace like “ubuntu” represents the canonical space for Ubuntu boxes. This is untrue. Namespaces on Atlas behave very similarly to namespaces on GitHub, for example…I would highly recommend trying the bento boxes instead.
The bento boxes are open source and they are built using best practices and Packer.
You’re probably thinking that well, the problems with using the Ubuntu boxes in the Ubuntu namespace are minor. Wrong. Networking doesn’t work. What? How can this be? Don’t people need networking? Obviously, it’s Linux in a VM and you can get networking to work. It’s just an extra, rather unpleasant step.
Vagrant Problems with MongoDB and Meteor
I used the recommended bento/ubuntu-16.04 box and the install went smoothly. Unfortunately, meteor tries to write the mongodb files inside the build folder and this fails in the shared Vagrant folder.
I’m hoping for a happy scenario where I can use the Sublime editor on Windows directly on the same files in the Linux VM.
Without the shared folders working, I might as well just run Meteor natively on Windows or Linux. I also have Meteor working in a normal VirtualBox VM with shared folders and no-password ssh access. So, I can easily give up on Vagrant and get back to work.
But, Vagrant supports a nice workflow, so nice that I decide to fix the problem.
mount --bind solves the Meteor in Vagrant problem
File linking from the build directory in home to the shared
/vagrant/ folder that co-exists on Linux and Windows didn’t work. Thanks to this nice article, I found that
mount --bind does work.
This is the key line assuming that your build is in
/home/vagrant/meteorapp/ and your shared folder with Windows is in
sudo mount --bind /home/vagrant/meteorapp/.meteor/ /vagrant/meteorapp/.meteor/
To make this run at startup for the next reboot of your VM,
echo “sudo mount --bind /home/vagrant/meteorapp/.meteor/ /vagrant/meteorapp/.meteor/” >> ~/.bashrc && source ~/.bashrc
In the Vagrantfile I added this lines:
config.vm.network :forwarded_port, guest: 3000, host: 3000 config.vm.provider "virtualbox" do |v| v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] end
Now, after editing a HTML file using Sublime on Windows, the meteor application in the Linux VM will automatically publish the changes to
localhost:3000. I can use Firefox on Windows to view the web application.
Why Not Just Develop On Linux or Windows, not Both?
My main problem is that I am largely unfamiliar with Windows. I’ve used Linux since it first came out and before that I was on UNIX. There are many things on Windows that confuse me. From what I can tell from reading questions online, there are other people who would rather develop on Linux than power through installing Node, Ruby, Python, MongoDB and other tools on Windows. I’m not alone. Although I had high hopes for Linux Subsystem for Windows, I’ve found many limitations.
I need Windows for Adobe Creative Cloud, especially AfterEffects and Premiere Pro. Let’s be honest, Photoshop is also much nicer than Gimp if you’ve used both extensively.
The Person That Has the Most Fun Wins
I don’t really need to use Vagrant as I have a dedicated Linux machine for development. However, it’s nice to be able to manage Linux VMs with Vagrant. Despite the rough edges of Vagrant setup, it’s fun to use. It’s a joy really. If you haven’t already used Vagrant, I suggest giving it a look. If you have fun with Vagrant and learn cool techniques to help with developer relations, please share your ideas.