Vagrant Shell Provisioning runs but fails
bash, linux, shell, vagrant
Solution
The error message is quite clear actually: `/user/bin/env` does not exist.
Simply replace the first line in your bash script by:
#!/usr/bin/env bash
Problem
I have a simple vagrant box that I am building while working through a tutorial. I have built on the box here is my vagrant file. ``` # -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "precise32" config.vm.box_url = "http://files.vagrantup.com/precise32.box" config.vm.provision :shell, :path => "bootstrap.sh" #config.vm.network "forwarded_port", guest: 80, host: 8080 end ``` This seems to work fine and is waiting for some other configuration but the problem I am having with the provisioning. It finds the Shell script fine with no errors. It even builds the vagrant box. However when it finishes I get this error ``` ==> default: stdin: is not a tty ==> default: bash: /tmp/vagrant-shell: /user/bin/env: bad interpreter: No such file or directory The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed! chmod +x /tmp/vagrant-shell && /tmp/vagrant-shell Stdout from the command: Stderr from the command: stdin: is not a tty bash: /tmp/vagrant-shell: /user/bin/env: bad interpreter: No such file or directory ``` When I ssh in nothing I setup to install is installed. When I run the bash script in the terminal command by command it works. Here is my bash script. ``` #!/user/bin/env bash #install sudo apt-get update sudo apt-get install -y python-software-properties sudo add-apt-repository -y ppa:ondrej/php5 sudo apt-get update sudo apt-get install -y wget php5 apache2 php5-mcrypt php5-curl git sudo apt-get update #apache onfig sudo a2enmod rewrite #Symlink for local development #remove the WWW for Apache sudo rm -rf /var/www #symlink for local directory ln -fs {PATH TO LOCAL PROJECT} /var/www sudo ln -fs /pathtolocaldirectory /var/www #Restart Apache sudo service apache2 restart ```