hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.05k stars 4.42k forks source link

Vagrant up not working #13237

Open msslgomez opened 1 year ago

msslgomez commented 1 year ago

Debug output

Bringing machine 'homestead' up with 'virtualbox' provider... ==> homestead: Checking if box 'laravel/homestead' version '13.0.0' is up to date... ==> homestead: Clearing any previously set forwarded ports... ==> homestead: Clearing any previously set network interfaces... ==> homestead: Preparing network interfaces based on configuration... homestead: Adapter 1: nat homestead: Adapter 2: hostonly ==> homestead: Forwarding ports... homestead: 80 (guest) => 8000 (host) (adapter 1) homestead: 443 (guest) => 44300 (host) (adapter 1) homestead: 22 (guest) => 2222 (host) (adapter 1) ==> homestead: Running 'pre-boot' VM customizations... ==> homestead: Booting VM... There was an error while executing VBoxManage, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "bcee716e-2a65-4bf2-8f4e-e39880a7748d", "--type", "headless"]

Stderr: VBoxManage.exe: error: Could not open the medium 'C:\Users\Programador\VirtualBox VMs\homestead\ubuntu-20.04-amd64-disk001.vmdk'. VBoxManage.exe: error: VMDK: inconsistent references to grain directory in 'C:\Users\Programador\VirtualBox VMs\homestead\ubuntu-20.04-amd64-disk001.vmdk' (VERR_VD_VMDK_INVALID_HEADER). VBoxManage.exe: error: VMDK: inconsistent references to grain directory in 'C:\Users\Programador\VirtualBox VMs\homestead\ubuntu-20.04-amd64-disk001.vmdk' (VERR_VD_VMDK_INVALID_HEADER). VBoxManage.exe: error: VD: error VERR_VD_VMDK_INVALID_HEADER opening image file 'C:\Users\Programador\VirtualBox VMs\homestead\ubuntu-20.04-amd64-disk001.vmdk' (VERR_VD_VMDK_INVALID_HEADER) VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component MediumWrap, interface IMedium

Reproduction information

Vagrant version

Vagrant 2.3.7

Host operating system

I'm using Windows 11

Vagrantfile

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path(File.dirname(__FILE__))

homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
customizationScriptPath = confDir + "/user-customizations.sh"
aliasesPath = confDir + "/aliases"

require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')

Vagrant.require_version '>= 2.2.4'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exist? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
        config.vm.provision "handle_aliases", type: "shell" do |s|
            s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases && chown vagrant:vagrant /home/vagrant/.bash_aliases"
        end
    end

    if File.exist? homesteadYamlPath then
        settings = YAML::load(File.read(homesteadYamlPath))
    elsif File.exist? homesteadJsonPath then
        settings = JSON::parse(File.read(homesteadJsonPath))
    else
        abort "Homestead settings file not found in #{confDir}"
    end

    Homestead.configure(config, settings)

    if File.exist? afterScriptPath then
        config.vm.provision "Run after.sh", type: "shell", path: afterScriptPath, privileged: false, keep_color: true
    end

    if File.exist? customizationScriptPath then
        config.vm.provision "Run customize script", type: "shell", path: customizationScriptPath, privileged: false, keep_color: true
    end

    if Vagrant.has_plugin?('vagrant-hostsupdater')
        config.hostsupdater.remove_on_suspend = false
        config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
    elsif Vagrant.has_plugin?('vagrant-hostmanager')
        config.hostmanager.enabled = true
        config.hostmanager.manage_host = true
        config.hostmanager.aliases = settings['sites'].map { |site| site['map'] }
    elsif Vagrant.has_plugin?('vagrant-goodhosts')
        config.goodhosts.aliases = settings['sites'].map { |site| site['map'] }
    end

    if Vagrant.has_plugin?('vagrant-notify-forwarder')
        config.notify_forwarder.enable = true
    end
end

This is a fresh install of everything on my machine, the issue is the following, I install everything and run vagrant up the first time, it works, I can go into ssh and everything, I exit out of ssh and run vagrant halt, now immediately I try vagrant up again and get these errors.

What is happening, why is it failing and how can I fix it?

msslgomez commented 1 year ago

I'll leave this open since I'm not sure what the actual problem is but after many attempts I have it working. I tried destroying the box and remaking it at least 5 times without any improvement, I uninstalled VirtualBox and tried again, but no luck. After I uninstalled Vagrant and VirtualBox and deleted the folders .vagrant.d and .VirtualBox I reinstalled Vagrant and VirtualBox and this time it worked.

I believe I was getting this error a couple months ago and I managed to solve it using this comment as a guide, that didn't work this time.

Edit: This failed again with the same error, I'm at a complete loss as to what to do, nothing I've tried has worked and I can't find much online.

It always works the first time, when I run the first vagrant up the box gets created correctly but after doing vagrant halt and vagrant up again it fails. I don't even know what to try at this point.

I checked my environment variables, I removed the other disk from my computer, I uninstalled everything and reinstalled it, tried --provision, reload, and nothing helps at all. Please. I'm desperate.