Appendix A. Vagrant Environmental Variables
There are a handful of environmental variables you can set to control various aspects of Vagrant on your system. These environmental variables all have their uses, which are explained along with their function.
VAGRANT_CWD
VAGRANT_CWD can be set to change the working directory of Vagrant. By default, Vagrant uses the current directory you’re in. The working directory is important because it is where Vagrant looks for the Vagrantfile. It also defines how relative paths in the Vagrantfile are expanded, since they’re expanded relative to where the Vagrantfile is found.
This environmental variable is most commonly set when running Vagrant from a scripting environment.
As a simple example, if you wrote a bash script to bring up multiple Vagrant environments, it might look like this:
#!/usr/bin/env bashVAGRANT_CWD=/foo vagrant upVAGRANT_CWD=/bar vagrant up
VAGRANT_HOME
VAGRANT_HOME can be set to change the directory where Vagrant stores global state. By default this is set to ~/.vagrant.d, which is the .vagrant.d folder in your home folder.
The Vagrant home directory is where things such as boxes are stored, so it can actually become quite large on disk.
There are two common use cases for this environmental variable.
First, some people have small solid state drives as their main filesystem for speed, but also have a much larger, slower drive attached for larger files where speed doesn’t matter as much. In this case, to save disk space on the expensive ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access