Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Homestead's Vagrantfile: where is $confDir supposed to be set?

I'm dissecting Laravel Homestead's configuration. In the Vagrantfile is the following line:

confDir = $confDir ||= File.expand_path("vendor/laravel/homestead")

$confDir is mentioned nowhere before that line. Its value is nil and I wonder what would give it a value? Something from the CLI?

like image 844
badger Avatar asked Sep 28 '22 03:09

badger


1 Answers

A Vagrantfile is just a ruby script. In ruby, a dollar sign variable is a global variable.

Now, this still doesn't make much sense when just looking at the homestead Vagrantfile alone. However, that may not be the only Vagrantfile in use. As described in the vagrant documentation here, under "LOAD ORDER AND MERGING", Vagrantfiles are loaded in the following order:

  1. Vagrantfile packaged with the box that is to be used for a given machine.
  2. Vagrantfile in your Vagrant home directory (defaults to ~/.vagrant.d).
  3. Vagrantfile from the project directory.
  4. Multi-machine overrides if any.
  5. Provider-specific overrides, if any.

The homestead Vagrantfile is the file loaded in step 3. If you have a Vagrantfile in step 1 or 2 that sets the $confDir variable, then the homestead Vagrantfile will pick that up and use it.

like image 146
patricus Avatar answered Oct 02 '22 14:10

patricus