Win10 安装 Homestead 的 Vagrant up 命令遇到的问题
win10来安装确实挺折腾的,幸运的是折腾了几个小时,终于vagrant up
成功了,把踩的坑记录一下。
本人安装环境
- win10专业版
- VirtualBox-5.2.18-124319-Win
- vagrant_2.1.2_x86_64
- virtualbox.box 6.1.0
- git 2.9.2
(注:VirtualBox和vagrant都是写这篇分享时的最高版本,网上关于高版本不能安装的种种问题都是不存在的;virtualbox.box此时最高版本6.3.0,由于官网上的怎么也下载不了,就用目前别人已经分享的6.1.0版本)
遇到的问题
问题
The box 'lc/homestead' could not be found
解决:
1.打开Homestead\scripts\homestead.rb
文件
2.找到:config.vm.box = settings["box"] ||= "lc/homestead"
3.改为:config.vm.box = settings["box"] ||= "laravel/homestead"
问题
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Importing base box 'laravel/homestead'...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["import", "\\\\?\\C:\\Users\\pc\\.vagrant.d\\boxes\\laravel-VAGRANTSLASH-
homestead\\3.0.0\\virtualbox\\box.ovf", "--vsys", "0", "--vmname", "lt-
settler_default_1503535533318_57377_1517310872767_87094", "--vsys", "0", "--unit", "9", "--disk",
"C:\\Users\\\u5317\\VirtualBox VMs\\lt-settler_default_1503535533318_57377_1517310872767_87094\\box-
disk1.vmdk"]
Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
nterpreting \\?\C:\Users\pc\.vagrant.d\boxes\laravel-VAGRANTSLASH-homestead\3.0.0\virtualbox\box.ovf...
OK.
0%...
Progress state: VBOX_E_IPRT_ERROR
VBoxManage.exe: error: Appliance import failed
VBoxManage.exe: error: Could not create the directory 'C:\Users\?VirtualBox VMs\lt-
settler_default_1503535533318_57377_1517310872767_87094' (VERR_INVALID_NAME)
VBoxManage.exe: error: Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component ApplianceWrap,
interface IAppliance
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleImportAppliance(struct HandlerArg
*)" at line 886 of file VBoxManageAppliance.cpp
解决:
- 涉及到
C:/User/
下当前用户文件夹为中文改为英文的问题() -
打开VirtualBox.exe 到 管理 -> 全局设定 -> 常规 -> 默认虚拟电脑位置, 将路径中的中文改成英文
问题
VBoxManage.exe: error: Failed to create the host-only adapter
解决:
- 打开
homestead\scripts\homestead.rb
,将以下代码中的两处ip改为你配置Homestead.yaml
中设置的ip# Configure A Private Network IP if settings["ip"] != "192.168.10.10" config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10"
2.到你安装vagrant的目录下修改
action.rb
文件,将以下两行代码前附加#
注释掉,(比如我的在E:\vagrant\embedded\gems\2.1.2\gems\vagrant-2.1.2\plugins\providers\virtualbox\action.rb
)#b.use ClearNetworkInterfaces #b.use Network
(注:修改该文件可能涉及到权限问题无法修改,我当时是将其父文件夹virtualbox点击右键->授予访问权限->选当前登陆管理员然后共享就行了)
3.管理员权限打开VirtualBox.exe,去管理->主机网络管理器,将网卡改成手动配置,ipv4地址改为你配置Homestead.yaml
中设置的ip
4.重启电脑问题
vagrant up
命令执行到SSH auth method: private key
卡住,然后就报错timeout while waiting for the machine to boot.
了解决:
1.这个问题站长summer已经分享过一篇文章了:《Homestead 安装问题汇总》
2.根据那篇文章我只做了前三步,第四步在 BIOS 中开启虚拟化技术支持觉得好麻烦没试,然后就是一顿瞎操作成功了,具体瞎操作如下:
(1) 我发现卡住后,虽然报错timeout,但是我打开VirtualBox.exe却发现里面配置的Homestead状态是 正在运行
(2) 我索性运行了vagrant destroy --force
删除了虚拟机,然后再执行vagrant up
重新配置虚拟机
(3) 第(2)点操作可能会导致Could not rename the directory
报错,具体解决,执行vagrant destroy --force
先删除虚拟机,后将C:\Users\你的用户名\VirtualBox VMs
下的文件全部删除,然后就vagrant up
,就好了。
附:希望还在摸索的各位不要放弃,总能找到答案的。但至于网上什么重新安装VirtualBox和vagrant的,什么重装系统的,什么再换个电脑的,都是放屁。
- 打开
楼主把问题复杂化了。