首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Vagrant Shell Provisioning运行但失败

Vagrant Shell Provisioning运行但失败
EN

Stack Overflow用户
提问于 2014-07-16 11:12:02
回答 2查看 11.6K关注 0票数 2

我有一个简单的流浪箱,这是我在学习教程时构建的。我在这个盒子上建立了我的流浪汉文件。

代码语言:javascript
复制
# -*- 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脚本运行良好,没有任何错误。它甚至建立了流浪汉的盒子。但是,当它完成时,我会得到这个错误

代码语言:javascript
复制
==> 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脚本。

代码语言:javascript
复制
#!/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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-07-16 14:29:38

实际上,错误信息非常清楚:/user/bin/env不存在。

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

代码语言:javascript
复制
#!/usr/bin/env bash
票数 6
EN

Stack Overflow用户

发布于 2014-07-16 14:48:44

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

要解决此问题,请尝试

代码语言:javascript
复制
chmod 755 /tmp/

chmod +x /tmp/vagrant-shell

然后尝试执行该命令,它将安全地工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24771595

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档