dotless-de / vagrant-vbguest

A Vagrant plugin to keep your VirtualBox Guest Additions up to date
MIT License
2.88k stars 206 forks source link

Installation/Update of Virtualbox Guest Additions fails #351

Closed HubertSadecki closed 9 months ago

HubertSadecki commented 5 years ago

Environment:

Windows: 10 ver. 1803
Virtualbox version: 6.0.12r133076 # The same error occured for Virtualbox 5.2.26
Vagrant version: Vagrant 2.2.4

Using latest debian stretch (9.9.1) vagrant box:

  config.vm.box = "debian/stretch64"

And latest vagrant-vbguest:

vagrant-vbguest (0.19.0, global)

When running vagrant up or vagrant vbguest I got following error:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

apt-get install -y linux-headers-`uname -r` dkms

Stdout from the command:

Reading package lists...
Building dependency tree...
Reading state information...

Stderr from the command:

E: Unable to locate package linux-headers-4.9.0-9-amd64
E: Couldn't find any package by glob 'linux-headers-4.9.0-9-amd64'
E: Couldn't find any package by regex 'linux-headers-4.9.0-9-amd6
Volker-Weissmann commented 4 years ago

I had the same problem under Arch Linux. It disappeared seemingly randomly and now I can't reproduce it. I think it got fixed by either rebooting, pacman -Syu or running vagrant init debian instead of vagrant init debian/jessie64. My error output was:

[volker@battle ~]$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'debian/jessie64' version '8.11.1' is up to date... ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key ==> default: Machine booted and ready! /home/volker/.vagrant.d/gems/2.7.0/gems/vagrant-vbguest-0.23.0/lib/vagrant-vbguest/middleware.rb:24: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call /opt/vagrant/embedded/gems/gems/i18n-1.8.2/lib/i18n.rb:195: warning: The called method `t' is defined here [default] No Virtualbox Guest Additions installation found. Reading package lists... Building dependency tree... Reading state information... E: Unable to locate package linux-headers-3.16.0-9-amd64 E: Couldn't find any package by regex 'linux-headers-3.16.0-9-amd64' Hit http://security.debian.org jessie/updates InRelease Ign http://httpredir.debian.org jessie InRelease Hit http://httpredir.debian.org jessie Release.gpg Hit http://httpredir.debian.org jessie Release Hit http://security.debian.org jessie/updates/main Sources Hit http://httpredir.debian.org jessie/main Sources Hit http://httpredir.debian.org jessie/main amd64 Packages Hit http://security.debian.org jessie/updates/main amd64 Packages Reading package lists... Reading package lists... Building dependency tree... Reading state information... E: Unable to locate package linux-headers-3.16.0-9-amd64 E: Couldn't find any package by regex 'linux-headers-3.16.0-9-amd64' ==> default: Checking for guest additions in VM... default: No guest additions were detected on the base box for this VM! Guest default: additions are required for forwarded ports, shared folders, host only default: networking, and more. If SSH fails on this machine, please install default: the guest additions and repackage the box to continue. default: default: This is not an error message; everything may continue to work properly, default: in which case you may ignore this message. The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed!

apt-get install -y linux-headers-uname -r dkms

Stdout from the command:

Reading package lists... Building dependency tree... Reading state information...

Stderr from the command:

E: Unable to locate package linux-headers-3.16.0-9-amd64 E: Couldn't find any package by regex 'linux-headers-3.16.0-9-amd64'

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

glen-84 commented 4 years ago

@fnordfish Can you please reopen this issue and label it so that it doesn't get automatically closed?

DJviolin commented 4 years ago

I tried this solution, but still not able to silence the linux-headers-4.9.0-3-amd64 kernel update... Trying out apt-mark hold linux-headers-4.9.0-3-amd64 also throws error, because this is a non-existing package, there's nothing to hold back... As I understand if I install the current kernel linux-headers-4.9.0-12-amd64 with the linux-headers-amd64 linux-image-amd64 packages, I need to restart the VM in order to take effect. Can this be the issue why the vbguest provision process still want to install the older linux-headers-4.9.0-3-amd64 kernel update?

$vbguest_install = <<~HEREDOC_VBGUEST
    apt-get -y --force-yes update
    DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential linux-headers-amd64 linux-image-amd64 dkms
HEREDOC_VBGUEST

if opts[:vbguest] == true
    # VAGRANT_EXPERIMENTAL="typed_triggers" env var should be present!
    node.trigger.before :"VagrantPlugins::ProviderVirtualBox::Action::CheckGuestAdditions", type: :action do |trigger|
        trigger.info = "Trigger run before vagrant-vbguest install!"
        trigger.run_remote = {inline: $vbguest_install}
        node.vm.provision :reload
    end
else
    node.vbguest.auto_update = false
end

I tried to use vagrant-reload plugin, but the provision reload didn't triggered after installing build-essential linux-headers-amd64 linux-image-amd64 dkms.

I also want to ask is there any action to target vagrant-vbguest? So far I tried the following ones without luck:

VagrantVbguest::Installers::Debian
VagrantVbguest::Installers::Linux
vbguest

Only targeting VagrantPlugins::ProviderVirtualBox::Action::CheckGuestAdditions works and runs before checking the guest addition's version. As I understand this is one step before vagrant-vbguest provision process?

If anyone have some tips how to solve this issue using Vagrant triggers without writing custom classes, I'm all open.

@fnordfish This issue needs to be reopen because this effecting current dev environments which targeting legacy OS (like Stretch) in production. The currently hardcoded uname -r solution needs an alternative kernel update method behind a boolean to install build-essential linux-headers-amd64 linux-image-amd64 packages.

shrimpwagon commented 4 years ago

Yall..... my solution up top works best so far: #issuecomment-545391139

thenewguy commented 4 years ago

Observing issue with Windows 10 1909 and config.vm.box = "hashicorp/bionic64"

jamieburchell commented 3 years ago

This also appears to be an issue with the CentOS 8 boxes I used from here:

http://cloud.centos.org/centos/8/x86_64/images/CentOS-8-Vagrant-8.2.2004-20200611.2.x86_64.vagrant-virtualbox.box https://app.vagrantup.com/centos/boxes/8

Error: Unable to find a match: kernel-devel-4.18.0-193.6.3.el8_2.x86_64 and Error: Unable to find a match: kernel-devel-4.18.0-147.3.1.el8_1.x86_64

I was able to resolve by:

$ vagrant ssh
$ sudo dnf upgrade
$ sudo shutdown now
$ vagrant halt
$ vagrant up
riege-burghardt commented 3 years ago

For CentOS 8, please see: https://github.com/dotless-de/vagrant-vbguest#installer-specific-options-installer_options

Especially: c.vbguest.installer_options = { allow_kernel_upgrade: true }

That fixed my problem by installing the latest kernel and performing a reboot of the Vagrant VM before continuing the provisioning.

jpsecher commented 3 years ago

For Ubuntu, it is linux-headers-generic linux-image-generic instead of linux-headers-amd64 linux-image-amd64.

ijdoc commented 2 years ago

For CentOS 8, please see: https://github.com/dotless-de/vagrant-vbguest#installer-specific-options-installer_options

Especially: c.vbguest.installer_options = { allow_kernel_upgrade: true }

That fixed my problem by installing the latest kernel and performing a reboot of the Vagrant VM before continuing the provisioning.

This works for Ubuntu Focal (20.04) as well