首页 > 解决方案 > 无法创建仅主机适配器

问题描述

我的系统上有vagrant up的问题。我有错误,你可以在下面看到。我试过重新安装 VBox,Vagrant,关闭防火墙,检查 VBox 网络驱动程序并重新启动主机系统,但它不工作。

谢谢大家的帮助。

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "create"]

Stderr: 0%...
Progress state: E_FAIL
VBoxManage.exe: error: Failed to create the host-only adapter
VBoxManage.exe: error: SetupDiCallClassInstaller (DIF_INSTALLDEVICE) failed 
(0x00000002)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component 
HostNetworkInterfaceWrap, interface IHostNetworkInterface
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdeclhandleCreate(struct 
HandlerArg *)" at line 94 of file VBoxManageHostonly.cpp

VBox 版本 5.2.22

流浪者版本 2.2.0

主机操作系统 Win7 x64

来宾操作系统 Ubuntu-16.04.5-desktop-amd64

流浪文件

dir = File.dirname(File.expand_path(__FILE__))

require 'yaml'
require "#{dir}/puphpet/ruby/deep_merge.rb"
require "#{dir}/puphpet/ruby/to_bool.rb"

configValues = YAML.load_file("#{dir}/puphpet/config.yaml")

provider = ENV['VAGRANT_DEFAULT_PROVIDER'] ? ENV['VAGRANT_DEFAULT_PROVIDER'] : 'local'
if File.file?("#{dir}/puphpet/config-#{provider}.yaml")
  custom = YAML.load_file("#{dir}/puphpet/config-#{provider}.yaml")
  configValues.deep_merge!(custom)
end

if File.file?("#{dir}/puphpet/config-custom.yaml")
  custom = YAML.load_file("#{dir}/puphpet/config-custom.yaml")
  configValues.deep_merge!(custom)
end

data = configValues['vagrantfile']

Vagrant.require_version '>= 1.8.1'

Vagrant.configure('2') do |config|
  eval File.read("#{dir}/puphpet/vagrant/Vagrantfile-#{data['target']}")
end

标签: vagrantvirtual-machinevirtualboxvagrant-windows

解决方案


我发现所有其他解决方案都不起作用,直到我发现这篇文章: Laravel Vagrant Up SSH Problems

在 YAML 文件的结束标记之前添加下一个代码就可以了

 config.vm.provider "virtualbox" do |vb|
        vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
    end

推荐阅读