Windows 10 Ubuntu bash failing to install packages. Whenever I try install new package with below command, getting same error.
root@VASI-HOME-PC:/mnt/c/Users/vadap# apt-get install atom
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package atomThis is not just with atom pacakge but i tried installing other packages like pip as well and received same error.
38 Answers
Executed below 2 commands and then I was able to install the packages.
sudo apt update
sudo apt install python3-pipSource -
3System: Windows 10 Enterprise, Ubuntu Windows Subsystem for Linux.
I ran this command:
sudo apt-get install dos2unixI had this error:
E: Unable to locate package dos2unixI then ran:
sudo apt-get updateand then:
sudo apt-get install dos2unixand it installed properly.
The error you're getting is because "atom" isn't part of the default packages, but WSL does not support graphical applications like Atom so it would never work anyway.
I would recommend installing it for Windows which is available from their website atom.io.
To make sure a package is actually in the package system you can use apt search <whatever> or for a simpler output apt-cache search <whatever>.
NOTE: Do not do the following, but for completeness sake I'll add how to actually install it:
You need to add the atom repository with the following command: sudo add-apt-repository ppa:webupd8team/atom
After that you can install it by first updating the search cache with apt-get update and then installing the package with apt-get install atom.
Same error, solved after:
sudo vi /etc/apt/sources.list # add source
sudo apt update # update source cacheMy sources.list file:
deb bionic main restricted
deb bionic-updates main restricted
deb bionic universe
deb bionic-updates universe
deb bionic multiverse
deb bionic-updates multiverse
deb bionic-backports main restricted universe multiverse
deb bionic-security main restricted
deb bionic-security universe
deb bionic-security multiverseEdit this list according to your location, as some sources may not apply globally.
2Easiest solution for Non GUI packages installation in a fresh WSL
Just run the below commands in the terminal:
sudo apt-get update
sudo apt-get install your-package-nameThe error is generally observed when you have a fresh WSL configuration on windows. Thus, you need to update your apt-get package manager. However, as mentioned above, for packages that involve a GUI (Atom), it isnt supported by WSL out of the box.
What was working for me:
wsl --set-version Ubuntu-18.04 2or
wsl --set-version Ubuntu-20.04 2 This fixed it perfectly for me:
Reposting incase the link ever dies:
Step #1.
On the Ubuntu distro, create a file at this location /etc/wsl.conf.
The file should have the following configuration.
[network]
generateResolvConf = falseIf we don’t set this file, WSL will automatically load a default /etc/resolv.conf with default namesever configuration.
Shut down and restart the distro.
Step #2
Delete the default /etc/resolv.conf file.
sudo rm /etc/resolv.confCreate a new /etc/resolv.conf with the following entry.
nameserver 8.8.8.8Now, restart the WSL2 and open the distro again. The apt update on WSL2 should work like a charm.
Usually only updates packages is needed before:
sudo apt update 1