Vagrant.configure("2") 执行 |config| 时出现语法错误,同时尝试 运行 脚本文件
Syntax error at Vagrant.configure("2") do |config|, while trying to run a script file
当我尝试将以下脚本 运行 作为 shell 脚本时,我收到一条错误消息
./install_local.sh: line 8: syntax error near unexpected token `"2"'
./install_local.sh: line 8: `Vagrant.configure("2") do |config|'
这可能是什么原因? Vagrant source
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
config.vm.provision "shell", inline: <<-SHELL
SHELL
end
你有些困惑
您的脚本是 Vagrantfile 而不是 shell 脚本。将您的 install_local.sh
重命名为 Vagrantfile
和 运行 vagrant up
当我尝试将以下脚本 运行 作为 shell 脚本时,我收到一条错误消息
./install_local.sh: line 8: syntax error near unexpected token `"2"'
./install_local.sh: line 8: `Vagrant.configure("2") do |config|'
这可能是什么原因? Vagrant source
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
config.vm.provision "shell", inline: <<-SHELL
SHELL
end
你有些困惑
您的脚本是 Vagrantfile 而不是 shell 脚本。将您的 install_local.sh
重命名为 Vagrantfile
和 运行 vagrant up