Cannot install Wine

I am trying to install Wine, but this error comes up when doing the final step:

$ sudo apt install --install-recommends winehq-stable
[sudo] password for ocean: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
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.
 winehq-stable : Depends: wine-stable (= 6.0.2~hirsute-1)
E: Unable to correct problems, you have held broken packages.

How can I resolve this?


Solution 1:

You have added wrong repository of Wine. If you are running 20.04 LTS, then its codename is focal. The hirsute codename means 21.04, which is not your version. You have to remove wrong repository, then add correct one instead.

To fix the problem use the following terminal commands:

sudo add-apt-repository -r 'deb https://dl.winehq.org/wine-builds/ubuntu/ hirsute main'

sudo add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main'
sudo apt-get update
sudo apt install --install-recommends winehq-stable