【问题标题】:Vagrant Shell Provisioning runs but failsVagrant Shell Provisioning 运行但失败
【发布时间】:2014-07-16 03:12:01
【问题描述】:

我有一个简单的 vagrant box,我在学习教程时正在构建它。我在这个盒子上建立了我的流浪文件。

# -*- 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

这似乎工作正常,正在等待其他一些配置,但我在配置时遇到了问题。

它发现 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

当我什么都不做 ssh 时,我安装的设置已安装。当我通过命令在终端命令中运行 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

【问题讨论】:

    标签: linux bash shell vagrant


    【解决方案1】:

    错误信息其实很清楚:/user/bin/env不存在。

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

    #!/usr/bin/env bash
    

    【讨论】:

    • 这就是我将环境更改为 #!/bin/bash 并解决了问题。感谢您的帮助!
    • @AaronBlakeley 写的是我在 Windows 8.1 下的解决方案 - 将 #!/usr/bin/env bash 替换为 #!/bin/bash
    【解决方案2】:

    您的 /tmp 目录或脚本本身缺少权限,这可能是此执行问题的根本原因。

    要解决这个问题,请尝试

    chmod 755 /tmp/
    
    chmod +x /tmp/vagrant-shell
    

    然后尝试执行命令,就可以安全运行了。

    【讨论】:

      猜你喜欢
      • 2023-04-08
      • 1970-01-01
      • 2014-08-09
      • 2022-12-30
      • 1970-01-01
      • 2013-02-12
      • 2017-04-28
      • 2011-10-29
      • 2022-01-12
      相关资源
      最近更新 更多