Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'vagrant ssh -c COMMAND' behavior differs from running commands inside a 'vagrant ssh' session

This works:

vagrant ssh
cd /vagrant && grunt build

This doesn't:

vagrant ssh -c 'cd /vagrant && grunt build'

(exits with bash: grunt: command not found)

Why?

Reason I'm asking is that I have a shell script that deploys a site to GitHub Pages, and I wanted to add a build step at the beginning to get a fresh build right before deployment.

I also tried writing a shell script vagrant_build.sh like:

cd /vagrant
grunt build

and having vagrant run it with vagrant ssh -c 'bash /vagrant/vagrant_build.sh', but it still can't find grunt.

The docs say that vagrant ssh -c COMMAND runs a single command, do I need to take that 100% literally? I was interpreting it as 'anything you can fit in one line in a terminal'.

like image 929
Michael Taufen Avatar asked Jul 28 '14 03:07

Michael Taufen


1 Answers

because grunt is not in your vagrant's path. so give it absolute path.

cd /vagrant && /path/to/grunt build
like image 76
Farhadix Avatar answered Oct 17 '22 01:10

Farhadix