简体   繁体   中英

Vagrant bash aliases not updating

When I first initialized my vagrant box, I added some aliases to /vagrant/aliases which is automatically copied to /home/vagrant/.bash_aliases on each provision.

What I added at first worked pretty well for the first few months, then I decided to add some more. The new aliases aren't working at all.

I tried reprovisioning the box, and I SSH'd to the box to check the ~/.bash_aliases file and I can see all my new aliases are in there as expected...however, trying to use one of the new aliases produces a command not found error. All the old aliases still work.

What might be going on here?

To solve this, execute . ~/.bashrc . ~/.bashrc on the command line.

Then add the following to the bottom of ~/.bash_profile so that the aliases are loaded each time you SSH to the vagrant box:

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

You could also try to provission your VM again, you can do this typing

vagrant global-status

This will give you information about your virtual machines, each one of them has an specific ID, find the one that's running homestead, it should look like this

id       name    provider   state    directory                                        
--------------------------------------------------------------------------------------
1a2b3c4  default virtualbox running /home/dimitri/.composer/vendor/laravel/homestead

To provision again your VM and make the aliasses work without destroying your VM and creating it agait just run this command

vagrant provision 1a2b3c4

Keep in mind that the number at the end is the ID of your running VM

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM