启动Homestead时出错,认为这是由于Homestead.yaml中目录路径的格式所致
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: c:/Users/Charles W/.ssh/id_rsa.pub
keys:
- c:/Users/Charles W/.ssh/id_rsa
folders:
- map: d:/Dropbox (Personal)/code/Homestead/
to: /home/vagrant/code
sites:
- map: homestead.test
to: /home/vagrant/code/public
databases:
- homestead
我尝试转义带有\
的特殊字符,还尝试将"
放在整个路径上,仍然出现错误C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/psych.rb:377:in 'parse': (<unknown>): did not find expected key while parsing a block mapping at line 2 column 1 (Psych::SyntaxError)
在Windows 10上从gitbash运行vagrant up
时
如何正确格式化.yaml文件中的直接路径?
答案 0 :(得分:0)
错误消息有点误导,因为该错误实际上在第14行中。
folders:
- map: d:/Dropbox (Personal)/code/Homestead/
to: /home/vagrant/code
对齐方式错误,您可能是说
folders:
- map: d:/Dropbox (Personal)/code/Homestead/
to: /home/vagrant/code
某些解析器能够为您提供两个错误位置。例如,libyaml会告诉您:
did not find expected key
was found at document: 1, line: 14, column: 7
while parsing a block mapping at line: 2, column: 1
似乎ruby psych只是选择一个位置,在这种情况下,它是错误的位置。
因此,您的问题与转义无关。但是您可能还是想阅读my article on YAML quoting。