iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🪟

Installing deb packages on WSL2 Ubuntu

に公開
2026/01/10

When installing a deb package on Ubuntu in WSL2, I naively ran sudo apt install ./hoge.deb but ran into trouble with permissions and dependencies. Furthermore, when I used sudo gdebi hoge.deb, it triggered a warning that bothered me, so I am documenting the procedure that finally worked for me.

Environment

  • Windows 11 Pro 24H2
  • WSL2 (Ubuntu 24.04.1 LTS)
  • gdebi 0.9.5.7+nmu7

Steps

Installing gdebi

gdebi is a software tool that automatically resolves dependencies when installing a deb package locally.
First, install gdebi using apt.

sudo apt update
sudo apt install gdebi

Fixing gdebi

In my environment, the version of gdebi installed by the above command was 0.9.5.7+nmu7. However, depending on the version of Python installed, the following warning may occur when running gdebi:

/usr/bin/gdebi:113: SyntaxWarning: invalid escape sequence '\S'
  c = findall("[[(](\S+)/\S+[])]", msg)[0].lower()

This is caused by a specification change in Python 3.6 and occurs if the Python version installed in your environment is 3.6 or later. For reference, the Python version pre-installed on my Ubuntu on WSL2 was 3.12.3.
Since this is a regular expression escape rather than a Python string manipulation issue, the script should still work despite the warning. However, seeing the warning every time is not ideal, so let's fix the gdebi script directly.

While gdebi appears to be located in /usr/bin, running ls -l reveals that the actual file is in /usr/share/gdebi.

cd /usr/share/gdebi

After checking the permissions with ll, you will see it is -rwxr-xr-x, so run:

sudo chmod 777 gdebi

to change them.

Next, open the file with your preferred editor and insert r before the target string to process it as a raw string.

/usr/share/gdebi/gdebi
    try:
-        c = findall("[[(](\S+)/\S+[])]", msg)[0].lower()
+        c = findall(r"[[(](\S+)/\S+[])]", msg)[0].lower()
    except IndexError:
        c = "y"

Finally, run:

sudo chmod 755 gdebi

to restore the permissions.

With this, the annoying warning should no longer appear during execution.

Installing the deb package

sudo gdebi hoge.deb

That's all.

Discussion