在 Onedrive 資料夾專案中執行 vagrant up,為什麼會出現以下輸出錯誤訊息?

在 Onedrive 資料夾專案中執行 vagrant up,為什麼會出現以下輸出錯誤訊息?

我的流浪文件:

Vagrant.configure("2") do |config|

    config.vm.define "vm1" do |vm1|
      vm1.vm.box = "debian/buster64"
      vm1.vm.box.hostname = "debian-vm"
      vm1.vm.network "private_network", ip: "192.168.15.140"
    end

    vb1.vm.provider "virtualbox" do |vb1|
      vb1.customize ["modifyvm", :id, "--gui", false]         #changed
      vb1.customize ["modifyvm", :id, "--memory", "4092"]     #changed
      vb1.customize ["modifyvm", :id, "--cpus", "4"]          #changed
      vb1.customize ["modifyvm", :id, "--name", "debian-vm"]  #changed
    end

    vm1.vm.provision "shell" do |sh1|
      sh1.inline = "sudo apt-get update"
      sh1.inline = "sudo apt-get install wget ntpdate net-tools nano"
    end

    config.vm.define "vm2" do |vm2|
      vm2.vm.box = "centos7"
      vm2.vm.box.hostname = "centos7-vm"
      vm2.vm.network "private_network", ip: "192.168.15.142"
    end

    vb2.vm.provider "virtualbox" do |vb2|
      vb2.customize ["modifyvm", :id, "--gui", false]        #changed
      vb2.customize ["modifyvm", :id, "--memory", "4092"]    #changed
      vb2.customize ["modifyvm", :id, "--cpus", "4"]         #changed
      vb2.customize ["modifyvm", :id, "--name", "debian-vm"] #changed
    end

    vm2.vm.provision "shell" do |sh2|
      sh2.inline = "sudo yum check-update"
      sh2.inline = "sudo yum -y install wget ntpdate net-tools nano"
      sh2.inline = "curl -fsSL https://get.docker.com/ | sh"
      sh2.inline = "sudo systemctl start docker"
      sh2.inline = "sudo systemctl status docker"
      sh2.inline = "sudo systemctl enable docker"
      sh2.inline = "sudo ps -ef | grep dockerd"
    end

end

此 Vagranfile 的 cmder(終端)的輸出為:

C:\Users\Marlon\OneDrive\pipeline (master -> origin)
λ vagrant up
Vagrant failed to initialize at a very early stage:

There is a syntax error in the following Vagrantfile. The syntax error
message is reproduced below for convenience:

C:/Users/Marlon/OneDrive/pipeline/Vagrantfile:15: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
C:/Users/Marlon/OneDrive/pipeline/Vagrantfile:34: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('

答案1

語法錯誤,意外的 tSTRING_BEG,期望關鍵字_do 或“{”或“(”

這是一個後續錯誤,因為上一行有錯誤。

vb.cpus = 4

應引用該論點4,如下:

vb.cpus = "4"

答案2

我正在弄清楚並發現我存儲的位置沒有同步(OneDrive),然後我放入靜態資料夾並成功!

做了一些修復和一些命令並將最終作品放在這裡。

PS:剛剛發現,因為 Onedrive 聲稱有警告,而且我在某些資料夾中有很多大檔案。

Vagrant.configure("2") do |config|
  config.vm.provider "virtualbox" do |vb|
     vb.gui = false
     vb.memory = "4096"
     vb.cpus = "4"
  end

  config.vm.define "vm1" do |vm1|
      vm1.vm.box = "centos/7"
      vm1.vm.network "public_network", bridge: "en1: Realtek PCIe GBE Family Controller"
      vm1.vm.network "public_network", ip: "192.168.15.140"
      vm1.vm.hostname = "centos-vm"

      vm1.vm.provision "shell", inline: <<-SHELL
         sudo yum update
         sudo yum -y install wget ntpdate net-tools nano
         sudo curl -fsSL https://get.docker.com/ | sh
         sudo systemctl start docker
         sudo systemctl status docker
         sudo systemctl enable docker
         sudo ps -ef | grep dockerd
      SHELL
  end

  config.vm.define "vm2" do |vm2|
      vm2.vm.box = "debian/buster64"
      vm2.vm.network "public_network", bridge: "en1: Realtek PCIe GBE Family Controller"
      vm2.vm.network "public_network", ip: "192.168.15.142"
      vm2.vm.hostname = "debian-vm"

      vm2.vm.provision "shell", inline: <<-SHELL
         sudo apt-get update
         sudo apt-get install wget ntpdate net-tools nano
      SHELL
  end

end

相關內容