Jenssen
Jenssen

Reputation: 1871

Vagrant add to PATH

I've just installed vagrant now I would like to make for example vagrant up global. In the docs I read this:

Sometimes you may want to vagrant up your Homestead machine from anywhere on your filesystem. You can do this on Mac / Linux systems by adding a Bash function to your Bash profile. On Windows, you may accomplish this by adding a "batch" file to your PATH. These scripts will allow you to run any Vagrant command from anywhere on your system and will automatically point that command to your Homestead installation:

Mac / Linux

function homestead() {
    ( cd ~/Homestead && vagrant $* )
}

But when I add the code above to my ~/.bash_profile:

enter image description here

And restart the terminal vagrant up is not working globally. I have no experience with the ~/.bash_profile file.

I would appreciate it if someone could put me in the right direction

Upvotes: 0

Views: 3086

Answers (1)

gregory
gregory

Reputation: 12885

This bash function allows you to type things like: homestead up and it will change directories to Homestead and pass the vagrant command in front of any other vagrant command. homestead up means cd homestead, and vagrant up. Typing vagrant up doesn't invoke the function and vagrant isn't in your path.

What you're looking for is simply adding vagrant to your path. You may do this by adding the executable path of vagrant.

export PATH=$PATH:/usr/local/vagrant:

So, you're bash profile would read:

export PATH=$PATH:/usr/local/bin/:~/composer/vendor/bin:

Note: I'm guessing your vagrant is installed in /usr/local/bin; it might be installed elsewhere, in which case put the proper path in lieu of /usr/local/bin.

Upvotes: 2

Related Questions