我正在使用这个vagrantfile:
[Date] >= DATEADD(d, datediff(d, 0,getdate()),1)
由于我想安装Linuxbrew,我的 provision / setup.sh 此代码:
Double f = Math.random() * 100;
String number = String.valueOf(f);
System.out.println("Number is : " + number);
String[] seprate = number.split("\\.");
System.out.println(seprate.length);
但我检索错误:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
...bla bla bla bla bla...
config.vm.provision "shell", path: "provision/setup.sh"
end
如何解决这个问题?
答案 0 :(得分:1)
让我猜一下。在ruby命令
之前添加yes
yes | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)"
答案 1 :(得分:1)
运行脚本时出现问题 - 当您使用config.vm.provision "shell", path: "provision/setup.sh"
ranrant运行时,将以root
用户身份运行它,因此您不需要sudo
但是你应该像你的用户一样运行它config.vm.provision "shell", path: "provision/setup.sh", privileged: false
也不会为将来的会话保存导出,因此请将其添加到.bashrc
文件,例如echo PATH=$HOME/.linuxbrew/bin:$PATH >> .bashrc
,以便最终脚本看起来像
sudo apt-get update
sudo apt-get install --yes git-all libreadline-dev build-essential curl git m4 python-setuptools ruby texinfo libbz2-dev libcurl4-openssl-dev libexpat-dev libncurses-dev zlib1g-dev
yes | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)"
echo PATH=$HOME/.linuxbrew/bin:$PATH >> ~/.bashrc
export PATH=$HOME/.linuxbrew/bin:$PATH
brew doctor
如果您从脚本中运行brew,则需要导出,但请注意,brew医生可能最终会收到警告并且不会返回,因此您最终可能会看到流浪消息
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
最后,对于原始错误,@ BMW获得所有信用添加yes |
到命令将默认输入密钥的问题