Windows 使用 Homsetead 报错踩坑记录
在Windows中搭建Homsetead使用命令vagrant up 报错
$ vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
D:/HashiCorp/Vagrant/embedded/gems/2.2.6/gems/vagrant-2.2.6/plugins/provisioners/file/config.rb:20:in `expand_path': incompatible character encodings: UTF-8 and GBK (Encoding::CompatibilityError)
from D:/HashiCorp/Vagrant/embedded/gems/2.2.6/gems/vagrant-2.2.6/plugins/provisioners/file/config.rb:20:in `expand_path'
from D:/HashiCorp/Vagrant/embedded/gems/2.2.6/gems/vagrant-2.2.6/plugins/provisioners/file/config.rb:20:in `validate'
原因就是用户名是中文的
打开控制面板中更改用户类型

点击用户

选择更改用户名称改成英文名称

此时我们在运行vagrant up命令,结果发现还是报错

虽然我们修改了用户名称但是我们的文件还是中文的路径:C:\Users

现在我们右击此电脑选中管理
选择本地用户和组中的用户

右击Administrator选择属性

把账号已禁用取消掉,点击确定

注销当前账户,选择Administrator账户登陆,之后我们打开此电脑到C:\Users
吧文件改成英文名


现在修改注册表
windows+R打开运行,输入regedit点击确定即可

依次展开HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Profilelist
将其修改成对应的名字


到此就完成了,但是,我们要把以前的电脑的环境变量修改一下(有些需要修改)


再一次运行vagrant up发现还是报错………………
Command: ["import", "\\?\C:\Users\Administrator\.vagrant.d\boxes\lc-VAGRANTSLASH-homestead\
6.1.0\virtualbox\box.ovf", "--vsys", "0", "--vmname", "lt-settler_default_1529197839254_477_153171
0722519_67195", "--vsys", "0", "--unit", "9", "--disk", "C:\Users\Administrator\VirtualBox VMs\l
t-settler_default_1529197839254_477_1531710722519_67195\box-disk001.vmdk"]
Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting \?\C:\Users\Administrator.vagrant.d\boxes\lc-VAGRANTSLASH-homestead\6.1.0\virtualbox\
box.ovf...
OK.
0%...10%...20%...30%...40%...
Progress state: VBOX_E_FILE_ERROR
VBoxManage.exe: error: Appliance import failed
VBoxManage.exe: error: Code VBOX_E_FILE_ERROR (0x80BB0004) - File not accessible or erroneous file c
ontents (extended info not available)
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleImportAppliance(struct HandlerArg *)"
at line 886 of file VBoxManageAppliance.cpp
打开我们的Oracle VM VirtualBox软件,左上角管理的全局设定,默认电脑的虚拟位置改一下


此时我们再次运行vagrant up,结果他又报错了
...
...
There was an error while executing `VBoxManage`, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below. Command: ["startvm", "da766e1e-a423-4f4d-a37e-8523e39b294f", "--type", "headless"] Stderr: VBoxManage.exe: error: Raw-mode is unavailable courtesy of Hyper-V. (VERR_SUPDRV_NO_RAW_MODE_HYPER_V_ROOT) VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole

这个是因为我们开启了Hyper-V,也就是说用了它就不能用Docker。
以管理员的方式启动 CMD,输入 bcdedit 回车,结果如下图显示:

禁用掉 Hyper-V: bcdedit /set hypervisorlaunchtype off 然后重启电脑再运行 vagrant up 就成功了。如果要打开 Hyper-V:bcdedit /set hypervisorlaunchtype auto 需要重启电脑生效。
重启电脑,再次运行vagrant up命令,终于不在报错
成功
输入命令vagrant ssh

附上参考链接:
修改系统用户名:https://blog.csdn.net/tanzey/article/details/82657816
关闭HYper-V:https://learnku.com/articles/29420

本作品采用《CC 协议》,转载必须注明作者和本文链接
关于 LearnKu
推荐文章: