[ACCEPTED]-Specify headless or GUI from command-line-vagrant

Accepted answer
Score: 25

The GUI option is provider specific (and 9 only very few providers support it), so 8 it doesn't feel right for a top level vagrant 7 command to add a switch for it.

To my experience 6 the most common use cases for GUI are:

  • Running a desktop type machine, in which case the setting makes sense in the Vagrantfile
  • Debugging a boot etc. issue, when you just want to enable it for a moment

If 5 you anyway have a setup where it's normal 4 to switch the GUI on and off, you can use 3 environment variables. For example something 2 like this in Vagrantfile:

# Returns true if `GUI` environment variable is set to a non-empty value.
# Defaults to false
def gui_enabled?
  !ENV.fetch('GUI', '').empty?

Vagrant.configure('2') do |config|
  config.vm.provider 'virtualbox' do |v|
    v.gui = gui_enabled?

Then on command 1 line on a *nix system:

GUI=1 vagrant up

And on Windows:

set GUI=1
vagrant up

More Related questions