流浪者 - 消息:心理::语法错误:(<unknown>):在第 9 行第 1 列扫描简单键时找不到预期的':'



当我运行

vagrant up

我收到错误:

There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.
Path: /Users/darius/PhpstormProjects/api.notification.guru/Vagrantfile
Line number: 0
Message: Psych::SyntaxError: (<unknown>): could not find expected ':' while scanning a simple key at line 9 column 1

流浪者文件如下所示:

# -*- mode: ruby -*-
# # vi: set ft=ruby :
require 'fileutils'
Vagrant.require_version ">= 1.6.0"
CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "cloud-config")
CONFIG = File.join(File.dirname(__FILE__), "vm-config.rb")
CA_CERT_PATH = File.join(File.dirname(__FILE__), "certs/domain.pem")
# Defaults for config options defined in CONFIG
$num_instances = 1
$instance_name_prefix = "core"
$update_channel = "stable"
$image_version = "current"
$enable_serial_logging = false
$share_home = false
$vm_gui = false
$vm_memory = 1024
$vm_cpus = 1
$shared_folders = {}
$forwarded_ports = {}
# Attempt to apply the deprecated environment variable NUM_INSTANCES to
# $num_instances while allowing config.rb to override it
if ENV["NUM_INSTANCES"].to_i > 0 && ENV["NUM_INSTANCES"]
  $num_instances = ENV["NUM_INSTANCES"].to_i
end
if File.exist?(CONFIG)
  require CONFIG
end
# Use old vb_xxx config variables when set
def vm_gui
  $vb_gui.nil? ? $vm_gui : $vb_gui
end
def vm_memory
  $vb_memory.nil? ? $vm_memory : $vb_memory
end
def vm_cpus
  $vb_cpus.nil? ? $vm_cpus : $vb_cpus
end
Vagrant.configure("2") do |config|
  # always use Vagrants insecure key
  config.ssh.insert_key = false
  config.vm.box = "coreos-%s" % $update_channel
  if $image_version != "current"
      config.vm.box_version = $image_version
  end
  config.vm.box_url = "http://%s.release.core-os.net/amd64-usr/%s/coreos_production_vagrant.json" % [$update_channel, $image_version]
  config.vm.provider :virtualbox do |v|
    # On VirtualBox, we don't have guest additions or a functional vboxsf
    # in CoreOS, so tell Vagrant that so it can be smarter.
    v.check_guest_additions = false
    v.functional_vboxsf     = false
  end
  # plugin conflict
  if Vagrant.has_plugin?("vagrant-vbguest") then
    config.vbguest.auto_update = false
  end
  (1..$num_instances).each do |i|
    config.vm.define vm_name = "%s-%02d" % [$instance_name_prefix, i] do |config|
      config.vm.provider :virtualbox do |vb|
        vb.name = "api.notification.guru-%s" % [vm_name]
      end
      config.vm.hostname = vm_name
      if $enable_serial_logging
        logdir = File.join(File.dirname(__FILE__), "log")
        FileUtils.mkdir_p(logdir)
        serialFile = File.join(logdir, "%s-serial.txt" % vm_name)
        FileUtils.touch(serialFile)
        config.vm.provider :virtualbox do |vb, override|
          vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
          vb.customize ["modifyvm", :id, "--uartmode1", serialFile]
        end
      end
      if $expose_docker_tcp
        config.vm.network "forwarded_port", guest: 2375, host: ($expose_docker_tcp + i - 1), auto_correct: true
      end
      $forwarded_ports.each do |guest, host|
        config.vm.network "forwarded_port", guest: guest, host: host, auto_correct: true
      end
      config.vm.provider :virtualbox do |vb|
        vb.gui = vm_gui
        vb.memory = vm_memory
        vb.cpus = vm_cpus
      end
      ip = "172.17.3.#{i+100}"
      config.vm.network :private_network, ip: ip
      # Uncomment below to enable NFS for sharing the host machine into the coreos-vagrant VM.
      config.vm.synced_folder ".", "/home/core/shared", id: "core", :nfs => true, :mount_options => ['nolock,vers=3,udp,noatime']
      $shared_folders.each_with_index do |(host_folder, guest_folder), index|
        config.vm.synced_folder host_folder.to_s, guest_folder.to_s, id: "core-share%02d" % index, nfs: true, mount_options: ['nolock,vers=3,udp']
      end
      if $share_home
        config.vm.synced_folder ENV['HOME'], ENV['HOME'], id: "home", :nfs => true, :mount_options => ['nolock,vers=3,udp']
      end
      if File.exist?(CLOUD_CONFIG_PATH)
        config.vm.provision :file, :source => "#{CLOUD_CONFIG_PATH}", :destination => "/tmp/vagrantfile-user-data"
        config.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true
      end
      if File.exist?(CA_CERT_PATH)
        config.vm.provision :file, :source => "#{CA_CERT_PATH}", :destination => "/tmp/domain.pem"
        config.vm.provision :shell, :inline => "mv /tmp/domain.pem /etc/ssl/certs/domain.pem && update-ca-certificates > /dev/null", :privileged => true
      end
    end
  end
end

语法错误应位于第 9 行。我要求检查我的同事,他也使用它 - 他说行是一样的,他没有出错。

我在其他类似的帖子中看到检查yaml文件,但我不知道是哪些。我不认为有一些与此错误相关的错误。

这是一个symfony项目,我只看到供应商文件夹中某些包中的yml文件。所以它不应该有事可做。

有什么想法吗?

实际上它显示的是第 9 行,而不是流浪文件。它在前面的行中崩溃了:

CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "cloud-config")

然后我看到云配置文件有冲突,例如

<<<<<<<头

它无法读取该文件。我不知道这些冲突是如何到达那里的,因为云配置不在 git 中。

但是在我从 git cloud-config.dist 文件中复制了该行后,有一个临时板标签

discovery: https://discovery.etcd.io/<token>

并运行

vagrant up

此令牌被覆盖,计算机被拖欠。

最新更新