Vagrant-scp无法识别非默认盘符路径,如何从USB盘复制文件到虚拟机?
Vagrant-scp无法识别非默认盘符路径,如何从USB盘复制文件到虚拟机?
我完全懂你这个困扰!vagrant-scp的参数解析逻辑确实有点“轴”——它会把路径里的冒号当成虚拟机名称和远程路径的分隔符,所以你输入的D:\location里,D:直接被它当成了虚拟机名字,自然会报找不到对应VM的错误。
不过不用非得把文件复制到C盘,有几个直接解决的办法:
方法1:给本地路径套双引号
把包含盘符的完整本地路径用双引号包裹起来,让命令行把整个路径作为一个完整参数传递,这样vagrant-scp就不会把D:误判成虚拟机名了:
vagrant scp "D:\location" vmname:\otherlocation
方法2:用正斜杠替换反斜杠
在Windows环境下,命令行也支持用正斜杠作为路径分隔符,这样可以避开冒号带来的歧义:
vagrant scp D:/location vmname:\otherlocation
方法3:使用UNC路径格式
把盘符路径转换成Windows的UNC格式,这种写法不会触发vagrant-scp的虚拟机名解析逻辑:
vagrant scp \\localhost\D$\location vmname:\otherlocation
这些方法都能直接从你的USB盘(D盘)复制文件到虚拟机,不用再绕C盘的弯路啦。
另外补充一下你遇到的错误提示(方便其他遇到同样问题的人参考):
The machine with the name 'D' was not found configured for
this Vagrant environment.
还有vagrant-scp官方给出的用法:
Usage: vagrant scp <local_path> [vm_name]:<remote_path> vagrant scp [vm_name]:<remote_path> <local_path> Directories will be copied recursively. Options: --[no-]color Enable or disable color output --machine-readable Enable machine readable output -v, --version Display Vagrant version --debug Enable debug output --timestamp Enable timestamps on log output --debug-timestamp Enable debug output with timestamps --no-tty Enable non-interactive output -h, --help Print this help
备注:内容来源于stack exchange,提问作者vmonteco
相关产品推荐
相关产品推荐

