Skip to content
Michael Ornellas edited this page Feb 10, 2014 · 2 revisions

What to do when Vagrant stops working!

Vagrant is awesome, but even Vagrant has hiccups from time to time. This page is going to exist as a list of problems, and a list of possible solutions. Feel free to email mike@themakersquare with any problems encountered outside of the scope of this wiki!

The vagrant command has stopped responding!

Every once in awhile, usually after putting your laptop to sleep or changing wireless networks, the vagrant command will stop responding. Instead of getting the familiar dialog after running vagrant halt, or vagrant ssh, instead nothing happens. Often, this just means the Vagrant box has "hung" for whatever reason, so the easiest solution is to just kill the running box manually.

The way to do this is to open "VirtualBox", you can either do this by going into your Applications folder in Finder, or use Spotlight or Alfred to start the application. You should see a box labeled mks_default_... or similar with "running" underneath. If you go ahead and right-click on this box, and go to the "Close" and then "Power off" you can manually power down the system (equivalent to holding the power button down on a physical computer). After this, you should be able to return to your ~/code/mks directory and run vagrant up once more to restart your system and carry on your merry way.

vagrant up responds with an error about needing a Vagrant environment and wants me to run vagrant init!

This means that the directory you're in doesn't have a Vagrantfile to run. Your ~/code/mks directory should have a Vagrantfile in it by default, but if you accidentally delete or misplace this file, you can get it back by running the following command from your local machine: curl -o ~/code/mks/Vagrantfile https://raw.github.com/makersquare/osx-dotfiles/master/Vagrantfile

Remember: you have to have a Vagrantfile in the folder you run vagrant up from for it to work, just like you need a Gemfile in your folder for bundle install to work!

I can't find my files in Vagrant!

First of all, remember that your Vagrant machine is an entire virtual computer living in your local machine. This means it has its own files separate from the files on your local machine. What this means is, if you connect to Vagrant using vagrant ssh and make a bunch of directories in the Vagrant machine's home directory, they are NOT going to be accessible locally. The only directory that is shared between your local machine and your Vagrant machine is ~/code/mks on your local machine and /vagrant on your virtual machine. ANY OTHER FILES/DIRECTORIES WILL NOT BE SHARED AUTOMATICALLY

You can, however, create a shortcut to /vagrant if you find it hard to remember how to find by running the command listed here to make a directory called shared in your Vagrant machine's home directory that is a shortcut to /vagrant.

Again, if you want to share files between your local machine and Vagrant machine, they have to be in either ~/code/mks on your local machine, or /vagrant (~/shared, if you followed the directions above) on your vagrant machine.

local: ~/code/mks vagrant: /vagrant (or, optionally, ~/shared)

My error seems way crazier than the ones so far!

The first thing I'd try is to first restart your Vagrant machine using vagrant halt and then vagrant up again. If that doesn't work, I'd follow the instructions above to manually power down your system. If you do those steps, and that still doesn't work, try the following:

One of the nice parts about Vagrant is, if things get really, really messed up, it is trivial to destroy your current Vagrant box and rebuild again. If things seem to be going really bad (and googling doesn't seem to be helping), you can try running vagrant destroy from ~/code/mks, and, once that completes, running vagrant up again from the directory. It should rebuild your system from the mks.box we downloaded the first day, if it doesn't, email [email protected] and he should be able to give you personal assistance.