Vagrant Shell Provisioning运行但失败

Aar*_*ley 2 linux bash shell vagrant

在学习教程时,我有一个正在构建的简单的无用信息框。我已经在盒子上建立了,这是我的流浪文件。

# -*- 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
Run Code Online (Sandbox Code Playgroud)

这似乎工作正常,并且正在等待其他配置,但是配置存在问题。

它发现Shell脚本很好,没有错误。它甚至可以构建无聊的盒子。但是,当完成时,我会收到此错误

==> 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
Run Code Online (Sandbox Code Playgroud)

当我什么都不做时,我安装了要安装的安装程序。当我通过命令在终端命令中运行bash脚本时,它可以工作。这是我的bash脚本。

#!/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
Run Code Online (Sandbox Code Playgroud)

小智 6

该错误消息实际上很清楚:/user/bin/env不存在。

只需将bash脚本中的第一行替换为:

#!/usr/bin/env bash
Run Code Online (Sandbox Code Playgroud)

  • 这就是我将环境更改为#!/ bin / bash并解决了问题的原因。谢谢您的帮助! (2认同)