红宝石意外“:”,期待DMOZ目录(Ruby unexpected ':', exp

2019-10-21 04:13发布

我想建立无业游民在我的Ubuntu,当“无业游民”起来,它总是给我下面的错误语法错误,意外“:”,期待DMOZ目录config.vm.provision:外壳,路径:“vagrantprov.sh”

我检查了Vagrantfile,应该OK,谁能告诉我哪里出错? 谢谢。

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

Answer 1:

什么版本的红宝石,你运行? 命名ARGS语法( path: "..." )是从1.9的支持及以上的,也许你有一个较低的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


Answer 2:

红宝石<1.9? 老式哈希语法风格需要老版本的Ruby

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


Answer 3:

红宝石<1.9:

:a => 1

红宝石> = 1.9:

a : 1


文章来源: Ruby unexpected ':', expecting kEND