Ruby意外’:’,期待kEND

我想在我的Ubuntu上设置vagrant,当“vagrant up”时,它总是给我以下错误语法错误,意外’:’,期待kEND config.vm.provision:shell,路径:“vagrantprov.sh”

我检查了Vagrantfile,应该没关系,谁能告诉我错误在哪里? 谢谢。

# -*- 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 = "ubuntu/trusty64" # Share an additional folder to the guest VM. The first argument is # the path on the host to the actual folder. The second argument is # the path on the guest to mount the folder. And the optional third # argument is a set of non-required options. # config.vm.synced_folder "../data", "/vagrant_data" config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--memory", "1024"] end config.vm.provision :shell, path: "vagrantprov.sh" end 

你在运行什么版本的Ruby? 从1.9及更高版本支持命名的args语法( path: "..." ),也许你有一个较低的Ruby版本?

(1.8)

 1.8.7 :001 > puts "a", b: 1 SyntaxError: compile error (irb):1: syntax error, unexpected ':', expecting $end 

(1.9)

 1.9.3p429 :001 > puts "a", b: 1 a {:b=>1} => nil 

Ruby <1.9? 旧的Ruby版本需要旧式哈希语法样式

 config.vm.provision :shell, :path => "vagrantprov.sh" 

Ruby <1.9:

 :a => 1 

Ruby> = 1.9:

 a : 1