Skip to content
This repository has been archived by the owner on Jul 29, 2018. It is now read-only.

The :append_to_path option

Emiliano Ticci edited this page May 15, 2014 · 3 revisions

The :append_to_path option is the preferred way to specify an absolute path for the command to be executed. While it's perfectly possible to specify the full path into the :execute option, this latter approach has several disadvantages.

Example: Executing VBoxManage.exe on Windows

By default the path of the VBoxManage.exe (C:\Program Files\Oracle\VirtualBox\) is not included in the system path. Instead it is available into the VBOX_INSTALL_PATH environment variable.

If, for example, you want to start a virtual machine not managed by Vagrant before doing vagrant up, you could specify it (without using the :append_to_path option) in the following way:

config.trigger.before :up do
  run "'C:/Program Files/Oracle/VirtualBox/VBoxManage.exe' ..."
end

But this statement is:

  • Tricky (the command must be enclosed in quotes, must have the .exe extension, slashes must be reversed or escaped);
  • Incompatible with other operating systems, in case you would use your Vagrantfile on different machines.

Instead using the :append_to_path option you can simplify the Vagrantfile in this way:

config.trigger.before :up, :append_to_path => ENV["VBOX_INSTALL_PATH"] do
  run "vboxmanage ..."
end
Clone this wiki locally