Score:7

After installing youtube-dl on Ubuntu 21.10 with the instructions on github many applications, including default text editor, broke

ca flag

A new user here, running ubuntu on version 21.10 impish.

I was installing youtube-dl with the instructions on the github page (https://github.com/ytdl-org/youtube-dl#installation):

$ sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
$ sudo chmod a+rx /usr/local/bin/youtube-dl

After the commands had downloaded the python script, multiple applications stopped functioning completely, as if they had been replaced by youtube-dl [UPDATE 3: the applications themselves weren't replaced, merely their links and shortcuts]. Some of the software affected were Ubuntu's default applications, like the default text editor (gedit) and the gnome-calculator, while others were manually installed like qbittorrent and steam.

Some things like firefox, nano, and lutris are still working.

Trying to run the text editor for example from terminal results in following output:

$ gedit

Usage: gedit [OPTIONS] URL [URL...]

gedit: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

The error is same with all the affected applications:

$ gnome-calculator

Usage: gnome-calculator [OPTIONS] URL [URL...]

gnome-calculator: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

Only thing I've tried so far is reinstalling gedit via apt but nothing changed.

I'd like to know what went wrong, and if it's fixable or if I need to do a reinstall.

UPDATE 1: Outputs of requested commands:

$ history 

  867  sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
  868  sudo chmod a+rx /usr/local/bin/youtube-dl
  869  youtube-dl sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
  870  sudo chmod a+rx /usr/local/bin/youtube-dl

No clue why it seems be listed twice.

$ which gedit
/usr/local/bin/gedit

$ which gnome-calculator
/usr/local/bin/gnome-calculator

$ ls -al $(which gedit)
lrwxrwxrwx 1 root root 17 loka   28 19:55 /usr/local/bin/gedit -> /usr/bin/firejail

$ ls -al $(which gnome-calculator)
lrwxrwxrwx 1 root root 17 loka   28 19:55 /usr/local/bin/gnome-calculator -> /usr/bin/firejail

$ file $(which gedit)
/usr/local/bin/gedit: symbolic link to /usr/bin/firejail

$ file $(which gnome-calculator)
/usr/local/bin/gnome-calculator: symbolic link to /usr/bin/firejail

"loka" seems to be short for October, I've got the system in English but the date seems to still use Finnish.

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

UPDATE 2: further requested command outputs from :

The fsck ran via a thumb drive

$ sudo fsck -p /dev/nvme0n1p1
fsck from util-linux 2.36.1
fsck.fat 4.2 (2021-01-31)
/dev/nvme0n1p1: 11 files, 1336/130812 clusters

$ sudo fsck -p /dev/nvme0n1p2
fsck from util-linux 2.36.1
/dev/nvme0n1p2: clean, 478908/31227904 files, 49277410/124895488 blocks

Back on the system:

$ whereis gedit
gedit: /usr/bin/gedit /usr/lib/x86_64-linux-gnu/gedit /usr/local/bin/gedit /usr/share/gedit /usr/share/man/man1/gedit.1.gz

$ sha256sum /usr/bin/gedit /usr/local/bin/youtube-dl
27545f7fb059c356feeb88a872719c074d0fd5169564ec3fbb3cbb312b093184  /usr/bin/gedit
7880e01abe282c7fd596f429c35189851180d6177302bb215be1cdec78d6d06d  /usr/local/bin/youtube-dl

Tried to use sudo ldconfig as well, as suggested by the answer, but got no output nor did anything seemingly change.

UPDATE 3: Just now found out that all the affected software still work with the full path (e.g./usr/bin/gedit), the issue seems to have to do with links and shortcuts to these applications. Things like the right-click option "Open with Text Editor" is also still broken.

Organic Marble avatar
us flag
I'd venture a guess that you typed something wrong with those 2 sudo commands. Can you find them in the output of `history` and confirm that what was typed was what was expected?
N0rbert avatar
zw flag
Can't reproduce on fresh VM. Please add the output of the following commands to the question: `which gedit`, `which gnome-calculator`, `ls -al $(which gedit)`, `ls -al $(which gnome-calculator)`, `file $(which gedit)`, `file $(which gnome-calculator)`, `echo $PATH`.
karel avatar
sa flag
Does this answer your question? [How can I update youtube-dl?](https://askubuntu.com/questions/380438/how-can-i-update-youtube-dl)
qwr avatar
kr flag
qwr
Btw I recommend installing from pip instead from apt because it will be more up-to-date. Also youtube-dl is currently paused as a project so consider yt-dlp fork for the time being.
ag flag
And this, kids, is why you don't run arbitrary scripts from the internet as root.
Score:23
cn flag
jpa

Here is a theory:

Before you ran the first command, /usr/local/bin/youtube-dl already existed and was a symlink to /usr/bin/firejail. Probably from some previous installation.

The curl ... -o /usr/local/bin/youtube-dl command does not replace the existing symlink with a new file. Instead it overwrites the contents of the file, which overwrites /usr/bin/firejail. Normally this is a multicall binary that checks the name it is called with and executes the actual application in a sandbox. But the youtube-dl code of course does nothing of that.

As confirmed in the comments, reinstalling firejail replaces /usr/bin/firejail with a working version.


For reference, the typical firejail configuration setup by firecfg works like this: for each sandboxed application, there is a symbolic link under /usr/local/bin that points to /usr/bin/firejail. The real executable is in /usr/bin and gets executed inside the sandbox. That is also why starting the programs with a full /usr/bin path still works, but the default path selects the symlink instead.

Organic Marble avatar
us flag
Nice analysis! I learned from this.
cn flag
I just came back to write something similar, now I don’t have to. Since the damage was limited, I actually find this somewhat amusing, because without the additional information that was added into the question, it did indeed look rather implausible.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.