How to Install and Update VirtualBox 7 and Vagrant Without Errors

Installing VirtualBox 7 and Checking the Existing Version

Recently, VirtualBox 7 was released, so I decided to install it along with Vagrant. First, let’s check if an older version of VirtualBox is already installed on this PC.

dpkg -l | grep virtualbox

Upon checking, I found that VirtualBox 6.1 was installed. Similar to Windows, I attempted to install the new version by executing the following command:

sudo apt install virtualbox

However, instead of installing VirtualBox 7, it updated to version 6.1. Therefore, I decided to download and install the latest version directly from the official website.

Here is the official website URL: https://www.virtualbox.org/

Use the following commands to download and install the file:

wget [Downloaded URL]
sudo dpkg -i [Downloaded File Name]

Errors During Installation and Uninstalling VirtualBox

An error occurred, and I was unable to install VirtualBox 7.0. The error message was as follows:

You are about to install a previously unselected package: virtualbox-7.0.
dpkg: Considering removal of virtualbox in favor of selecting virtualbox-7.0…
dpkg: no, cannot proceed with removal of virtualbox (–auto-deconfigure will help):
virtualbox-qt depends on virtualbox (= 6.1.38-dfsg-3~ubuntu1.22.04.1)
The package virtualbox is about to be removed.

dpkg: Considering the fact that virtualbox-7.0_7.0.0-153978~Ubuntu~jammy_amd64.deb contains virtualbox-7.0:
virtualbox-7.0 conflicts with virtualbox
virtualbox (version 6.1.38-dfsg-3~ubuntu1.22.04.1) is provided and installed.

dpkg: An error occurred while processing the archive virtualbox-7.0_7.0.0-153978~Ubuntu~jammy_amd64.deb (–install):
Package conflict – virtualbox-7.0 will not be installed.
Errors were encountered while processing:
virtualbox-7.0_7.0.0-153978~Ubuntu~jammy_amd64.deb

Uninstalling the Old Version of VirtualBox

It seems that the new version cannot be installed without first removing the old version of VirtualBox. Use the following command to remove the old version:

sudo apt remove --purge virtualbox

Reinstalling VirtualBox 7 and Installing Missing Packages

To reinstall VirtualBox 7, run the following command:

sudo dpkg -i [Downloaded File Name]

The installation output was as follows:

(Reading database … Currently 146255 files and directories are installed.)
Preparing to unpack virtualbox-7.0_7.0.0-153978~Ubuntu~jammy_amd64.deb …
Unpacking virtualbox-7.0 (7.0.0-153978~Ubuntu~jammy) …
dpkg: dependency problems prevent configuration of virtualbox-7.0:
virtualbox-7.0 depends on libqt5help5 (>= 5.15.1); however:
Package libqt5help5 is not installed.
virtualbox-7.0 depends on libqt5xml5 (>= 5.0.2); however:
Package libqt5xml5 is not installed.

dpkg: error processing package virtualbox-7.0 (–install):
dependency problems – leaving unconfigured
Processing triggers for hicolor-icon-theme (0.17-2) …
Processing triggers for shared-mime-info (2.1-2) …
Errors were encountered while processing:
virtualbox-7.0

This error occurred because some necessary packages were not installed. To install the missing packages, execute the following command:

sudo apt install libqt5help5 libqt5xml5

Package Dependency Errors and How to Fix Them

During the installation of VirtualBox 7, I encountered issues with package dependencies, resulting in the following error message:

Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
You might want to run ‘apt –fix-broken install’ to correct these.
The following packages have unmet dependencies:
libqt5help5 : Depends: libqt5sql5 (>= 5.3.0) but it is not going to be installed
E: Unmet dependencies. Try ‘apt –fix-broken install’ (or specify a solution).

This error indicates that the dependencies between the packages being installed have not been resolved. To fix this issue, execute the command suggested in the error message:

sudo apt --fix-broken install

Verifying the Installation of VirtualBox and Setting Up Vagrant

After resolving the dependency issues with the commands mentioned earlier, I attempted to install VirtualBox again. This time, the installation completed successfully. To verify the installed version of VirtualBox, run the following command:

VBoxManage -v

This command confirmed that VirtualBox 7 was successfully installed.

Next, assuming that Vagrant is already installed, I will check if the virtual machines can start up correctly. Detailed instructions for installing Vagrant can be found on the official website.

Here is the official website URL: https://www.vagrantup.com/

Steps for Installing Vagrant

If you are working as a regular user, use sudo to execute the commands. To configure the system for installing Vagrant, run the following commands:

wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

sudo apt update && sudo apt install vagrant

Verifying Vagrant Version and Starting a Virtual Machine

First, let’s verify the version of Vagrant that was installed to ensure it was correctly installed. Execute the following command:

vagrant version

Running this command will display the version information for Vagrant. Once you’ve confirmed that the correct version is installed, the next step is to start a virtual machine and verify its operation.

To start the virtual machine, use the following command:

vagrant up

Virtual Machine Startup Errors and Manual Installation of Vagrant

When attempting to start the virtual machine, the following error occurred:

The provider ‘virtualbox’ that was requested to back the machine
‘default’ is reporting that it isn’t usable on this system. The
reason is shown below:

Vagrant has detected that you have a version of VirtualBox installed
that is not supported by this version of Vagrant. Please install one of
the supported versions listed below to use Vagrant:

4.0, 4.1, 4.2, 4.3, 5.0, 5.1, 5.2, 6.0, 6.1

A Vagrant update may also be available that adds support for the version
you specified. Please check www.vagrantup.com/downloads.html to download
the latest version.

This error message indicates that the version of VirtualBox installed is not supported by Vagrant. To resolve this issue, you need to manually install the latest version of Vagrant.

To install the latest version of Vagrant, use the following command. In this example, version 2.3.2 is installed, but if a newer version is available, use that instead:

sudo rpm -Uvh https://releases.hashicorp.com/vagrant/2.3.2/vagrant-2.3.2-1.x86_64.rpm

Due to an update in the article, here is the latest URL:

https://releases.hashicorp.com/vagrant/2.4.1/vagrant-2.4.1-1.x86_64.rpm

RPM Installation and Vagrant Initialization Errors

Vagrant installation requires RPM, which may not be installed by default. If it’s not installed, use the following command to install RPM:

sudo apt install rpm

After installing Vagrant and attempting to verify the version, the following error message appeared:

Vagrant failed to initialize at a very early stage:

The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:

vagrant plugin repair

If Vagrant was recently updated, this error may be due to incompatible
versions of dependencies. To fix this problem please remove and re-install
all plugins. Vagrant can attempt to do this automatically by running:

vagrant plugin expunge –reinstall

Or you may want to try updating the installed plugins to their latest
versions:

vagrant plugin update

Error message given during initialization: Unable to resolve dependency: user requested ‘vagrant-vbguest (= 0.30.0)’

This error is caused by a dependency issue with the Vagrant plugins. You can resolve the issue by repairing, reinstalling, or updating the plugins using the following methods:

Repairing Plugins: Run the following command to repair the plugins:

vagrant plugin repair

However, this method may not always resolve the issue.

Reinstalling Plugins: If repairing does not work, reinstall the plugins using the following command:

vagrant plugin expunge --reinstall

Updating Plugins: Finally, you can attempt to resolve the issue by updating the plugins with the following command:

vagrant plugin update

After performing these steps, check the Vagrant version again, and you should be ready to launch your virtual machine.

However, if you encounter an issue where the virtual machine freezes during startup, it may be because the old version of VirtualBox was not completely removed. To resolve this issue, run the following command to completely remove the old VirtualBox:

sudo apt remove virtualbox*

After executing this command, the virtual machine should start up without any issues.

How to Handle Uninstallation Failures of VirtualBox

If you encounter failures when trying to uninstall an old version of VirtualBox, you may need to stop any related VirtualBox services first. Execute the following command to stop the service:

sudo service vboxdrv stop

Next, to ensure that the stopped service is not still running as a process, check the Process ID (PID). You can retrieve the PID with the following command:

pidof VBoxSVC

This command will display the process ID of the VBoxSVC service. To forcibly terminate this process, use the following command:

sudo kill -9 [Displayed PID Number]

By entering the displayed PID number into the command above and executing it, you can forcibly terminate the service and stop the process that is preventing the uninstallation. You can then attempt to uninstall VirtualBox again.

In the end, I believe following the steps below will help you avoid encountering errors. I created the article based on what I actually did, so I worked through resolving errors as I went along.

How to Install or Update VirtualBox and Vagrant

  1. Installing or Updating VirtualBox

First, here are the steps to install or update VirtualBox.

1.1 Removing the Old Version (if necessary)

If an old version of VirtualBox is installed, remove it first. To uninstall it, execute the following command:

sudo apt remove --purge virtualbox*

1.2 Installing the Latest Version

Next, install the latest version of VirtualBox. Use the .deb file downloaded from the official website for installation:

wget [URL obtained from the official VirtualBox website]
sudo dpkg -i [Downloaded File Name]

If dependency errors occur, run the following command to install the missing packages:

sudo apt --fix-broken install

With this, the installation of VirtualBox will be complete.

2. Installing or Updating Vagrant

Next, I will explain the steps to install or update Vagrant.

2.1 Installing Vagrant

To install Vagrant, first, add the necessary GPG key and repository. Run the following commands:

wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

sudo apt update && sudo apt install vagrant

Next, install Vagrant:

sudo apt install vagrant

2.2 Updating Vagrant

If Vagrant is already installed, you can update it to the latest version using the following commands:

sudo apt update
sudo apt upgrade vagrant

With this, the installation or update of Vagrant will be complete.

Please share if you like it!
TOC