Repairing a Variable VVV Install

I don’t know what I am from a development point of view. I started out as a front-end developer, but one that had the design skills akin to Donald Trump’s abilities in the art of tact, wit and diplomacy. I quickly left the design to other people and developed a vast array of IE6 hacks that would (and should) make Bill Gates blush. As time has gone on, I have becoming increasingly fascinated with code design patterns and coding that does clever things behind the scenes. I have one formal qualification, an A-Level in computing that I received in 1997. Maybe I should know my place and leave the higher level stuff to the qualified and learned members of the computing world, or maybe my quest to learn should be praised. Who knows? What I do know is that my attempts to write better code, learn more and generally be a better developer seem to hit the wall with alarming frequency of late. The main issue I encounter is that there is a lot of assumed knowledge involved with higher level “things”.

One such “thing” is the development environment. I was happy with XAMPP for years. Then I learned about PHPUnit. I hacked around for ages to get that installed. Then someone mentioned codesniffer and WP CLI. Eventually after resisting for ages, I installed vagrant and VVV. It took a day of hacking around, finding answers to issues, googling for translations of what those answers meant, and googling for translations of those translations. I wasn’t quite down to “What is Terminal on a Macbook”, but I wasn’t far off. That said, once I was up and running, I loved Vagrant, and the humbling experience of trying to install it was safely in the past. Until this morning.

This morning, my past came back to haunt me like something out of a bad soap opera. Same routine as always. Make a coffee, sit at my desk and vagrant up. At this point, I have to disclose that I pulled some code from the VVV develop branch at some point between this vagrant up and the last. Lesson one: use stable releases. Leave the bleeding-edge to people who don’t pass out at the sight of digital blood. I googled the errors and got a multitude of posts. Unfortunately the error was fairly generic and generated by a provisioning script that attempts a ton of different things. I still don’t know what broke the install.

After a morning of much wailing and gnashing of teeth, vagrant ups and downs (ok so its vagrant halt but I’m being lyrical now), deleting virtual machines with reckless abandon and then a long lunch with a friend who has limited tech knowledge and could be relied upon not to mention anything involving vagrant, I finally got to the solution. Its probably ridiculously long winded. Its probably laughable to anyone with a higher level of tech knowledge than me (please let me know if you do, and it is via the comments), but it got me back on track, and so, on the off chance that you are in the same murky tech middle ground between n00b and someone who actually know’s what they’re doing, here’s what I did:

1. Updated Vagrant

cd ~/vagrant/vagrant-local
vagrant version

2. Updated Virtualbox
Open Virtualbox as you would open any software.
Check for updates (on Mac Virtualbox menu/Check for Updates).

3. Backup old VVV folder
In my case, I renamed my vagrant-local directory to “vagrant-localxxx”.
Make sure that you do this, as you will need files from your old install further along this process.
My friend who I helped with this same issue didn’t and had to rebuild his host files from scratch. Luckily there weren’t many for him to rebuild.

4. Begin a fresh VVV install
Create a new vagrant-local directory. Download the latest stable version of VVV to it and unpack it.

5. Removed my vagrant virtual box from Virtualbox.
Open Virtualbox. Right click on your box (in my case “vagrant-local”) click “Remove”.

6. Installed the vagrant-vbguest plugin

cd ~/vagrant/vagrant-local
vagrant plugin install vagrant-vbguest

When installed, it keeps the kernel modules of your guest synchronized with the version of your host whenever you do vagrant up. If you know exactly what this means, you’re punching below your weight reading this post, my take on it is that is can prevent some shared folder errors, which I was certainly getting and which were causing me to shout a lot and throw things.

7. Update all other plugins

cd ~/vagrant/vagrant-local
vagrant plugin update

I use the hostsupdater, share and triggers (as well as the newly installed vbguest) plugins.

8. Restart Vagrant

cd ~/vagrant/vagrant-local
vagrant up

You will probably wait a looooooong time for VVV to install everything.
Read a book or go for lunch.
Once it finishes, check in your browser. All your default WP installs and PhPMyAdmin should be present and correct.

Stop Vagrant.

cd ~/vagrant/vagrant-local
vagrant halt

9. Restore Sites
Copy all sites from the vagrant-localxxx/www directory to the vagrant-local/www directory.
You can exclude any that you already have entries for like the default WP installs.

10. Copy Provisioning Scripts
Copy the following from vagrant-localxxx/provision to vagrant-local/provision


10. Restore Databases
Copy all site databases from vagrant-localxxx/database/backups to vagrant-local/database/backups
You can exclude any that you already have entries for like the default WP installs.
Copy vagrant-localxxx/database/init-custom.sql to vagrant-local/database/init-custom.sql

11. Restore Nginx Config
Copy contents of vagrant-localxxx/config/nginx-config/sites to vagrant-local/config/nginx-config/sites
You can exclude any that you already have entries for like the default WP installs.

12. Fire up Vagrant and provision

cd ~/vagrant/vagrant-local
vagrant up --provision

13. Bonus round (and remember, 13 is unlucky for some)
If you use the hostsupdater plugin, you may wish to do the following:

Open vagrant-local/Vagrantfile
Amend line 105 from true to false

config.hostsupdater.remove_on_suspend = false

This leaves your hosts in your host file when you run vagrant halt thus negating the need to enter your sudo password every time in order to remove them (and inevitably forgetting this, going away to do something, coming back ages later and finding your vagrant still waiting for you. Like a vagrant).

That’s it. VVV restored. Nightmare over. To make things better, I was able to pass these notes to my friend (mentioned in point 3, who I bet you thought was hypothetical) who had the same issue and he also managed to resurrect his install. So, worse case, no one ever reads or follows these instructions, but I managed to use my experience to help one other struggling techie out.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.