Error while Installing VSCode on Ubuntu

Many users encounter challenges when installing Visual Studio Code (VS Code) on Ubuntu, especially when running it on a virtual machine. This article addresses a common error and provides a step-by-step solution.

My Environment

I am using Ubuntu 22.04, running on Parallel Desktop on a MacOS with an M2 Chip.

The Issue

While attempting to install VS Code, downloaded from the official website, using the following command:

sudo apt install ./code_1.85.1-1702462158_amd64.deb

I encountered dependency errors:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'code:amd64' instead of './code_1.85.1-1702462158_amd64.deb'
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
code:amd64 : Depends: libasound2:amd64 (>= 1.0.17) but it is not installable
Depends: libatk-bridge2.0-0:amd64 (>= 2.5.3) but it is not installable
Depends: libatk1.0-0:amd64 (>= 2.2.0) but it is not installable
Depends: libatspi2.0-0:amd64 (>= 2.9.90) but it is not installable
Depends: libc6:amd64 (>= 2.14) but it is not installable
Depends: libc6:amd64 (>= 2.16) but it is not installable
Depends: libc6:amd64 (>= 2.17) but it is not installable
Depends: libc6:amd64 (>= 2.2.5) but it is not installable
Depends: libcairo2:amd64 (>= 1.6.0) but it is not installable
Depends: libcurl3-gnutls:amd64 but it is not installable or
libcurl3-nss:amd64 but it is not installable or
libcurl4:amd64 but it is not installable or
libcurl3:amd64 but it is not installable
Depends: libdbus-1-3:amd64 (>= 1.5.12) but it is not installable
Depends: libdrm2:amd64 (>= 2.4.75) but it is not installable
Depends: libexpat1:amd64 (>= 2.0.1) but it is not installable
Depends: libgbm1:amd64 (>= 17.1.0~rc2) but it is not installable
Depends: libglib2.0-0:amd64 (>= 2.37.3) but it is not installable
Depends: libgssapi-krb5-2:amd64 but it is not installable
Depends: libgtk-3-0:amd64 (>= 3.9.10) but it is not installable
Depends: libgtk-3-0:amd64 (>= 3.9.10) but it is not installable or
libgtk-4-1:amd64 but it is not installable
Depends: libkrb5-3:amd64 but it is not installable
Depends: libnspr4:amd64 (>= 2:4.9-2~) but it is not installable
Depends: libnss3:amd64 (>= 2:3.30) but it is not installable
Depends: libnss3:amd64 (>= 3.26) but it is not installable
Depends: libpango-1.0-0:amd64 (>= 1.14.0) but it is not installable
Depends: libx11-6:amd64 but it is not installable
Depends: libx11-6:amd64 (>= 2:1.4.99.1) but it is not installable
Depends: libxcb1:amd64 (>= 1.9.2) but it is not installable
Depends: libxcomposite1:amd64 (>= 1:0.4.4-1) but it is not installable
Depends: libxdamage1:amd64 (>= 1:1.1) but it is not installable
Depends: libxext6:amd64 but it is not installable
Depends: libxfixes3:amd64 but it is not installable
Depends: libxkbcommon0:amd64 (>= 0.4.1) but it is not installable
Depends: libxkbfile1:amd64 but it is not installable
Depends: libxrandr2:amd64 but it is not installable
Recommends: libvulkan1:amd64 but it is not installable
E: Unable to correct problems, you have held broken packages.

The Solution

The key to resolving this issue lies in matching the architecture of your operating system with the correct VS Code build. Since my setup involves an ARM64 architecture on MacOS, I needed to download the ARM64 version of VS Code.

I downloaded the ARM64 .deb version from the Official Website and installed it using the terminal. This resolved the problem.

Conclusion

By downloading the correct version of VS Code that matches the system’s architecture, I successfully resolved the installation issue. This solution is particularly relevant for those running Ubuntu on virtual machines with different underlying hardware architectures. Always ensure to check the compatibility of your system with the software version you’re attempting to install.


For more tips and tricks on software installation and troubleshooting, stay tuned to this blog!