Steam For Linux’s Single Line Of Script That Deletes All Your Stuff

Steam For Linux’s Single Line Of Script That Deletes All Your Stuff

The PC gamer’s nightmare: Waking up one day to find your PC is barren of content. All your photos, games and other important data given the digital go-ahead to stop existing. A shoddy platter, virus or surge could be responsible, but no one would ever suspect Steam. Well, it’s more likely than you think for Linux users, going by a disastrous bug recently discovered with Valve’s software.

The issue was uncovered two days ago by user “keyvin”, and reported on Steam for Linux’s GitHub repository. After moving their Steam folder to another directory, keyvin fired up the program, only for it to crap out. Steam then reinstalled itself and everything “looked great”, until keyvin realised that the program had rather thoroughly cleaned up his hard drive:

…I looked and saw that steam had apparently deleted everything owned by my user recursively from the root directory. Including my 3tb external drive I back everything up to that was mounted under /media.

The report states that it’s likely not a “common problem”, but upon further investigation it seems the script responsible “does something in a really, really stupid way”. You’d think Valve would be a little more careful when it came to deleting things… but no.

Here’s where the issue occurs:

rm -rf "$STEAMROOT/"*

To put it simply, the code relies on the variable “$STEAMROOT” to contain the user’s Steam directory. If, for some reason, that variable isn’t populated correctly (the user has an atypical configuration or has moved their Steam folder) then the variable would be empty and the rm -rf command — essentially a “nuke from orbit” delete — would hit up the root directory instead and well… you can figure out the rest.

The thing is, the Windows version of Steam is a little blasé too. In the right (or wrong) circumstances, uninstalling the software can also delete things it shouldn’t:

Warning: The uninstallation process deletes the folder Steam was installed to to ensure it is fully uninstalled. If you accidentally installed Steam to a folder containing other data, for example C:Program Files instead of C:Program FilesSteam, STOP! Do not run the uninstaller and instead carefully follow the instructions below for Manually Removing Steam, except only delete Steam-related files in step 3.

Of course, in the case of Linux, simply moving a folder for a non-critical piece of software should never run the risk of wiping data. It looks like someone from Valve has been assigned to the issue, so hopefully it’ll be resolved soon.

Moved ~/.local/share/steam. Ran steam. It deleted everything on system owned by user. [GitHub, via PC World]


  • Fortunately on Linux, if the security is set correctly, this can’t destroy the operating system (such a thing could on Windows) but that makes little difference if all the users precious content is gone.

  • You can never trust uninstallers. No matter what os you have.

    I wish more developers would create a log of what was installed and exactly where but very few do this.

  • I’m not at all a Linux user, but shouldn’t it just return an error saying “directory STEAMROOT does not exist” or something? Seems kind of like a bug with the rm -rf command in general if that’s the case.

  • So I hope I’m not 1 of a million linux users about to jump on you but here goes:

    $STEAMROOT is a variable name, the value of which defaults to “” if it has not been set (as all bash variables do). rm -rf “$STEAMROOT/”*then evaluates to rm -rf /*, which is basically go to the lowest directory and delete everything. The intention, of course, is go to the lowest part of the steam folder structure and delete everything. Really this is not a problem with rm. You could argue that it’s a problem with bash, but choosing default values for things is always hard.

    In practice steam should probably check whether $STEAMROOT is set to something before running this command. Also, as some other commenters have pointed out, steam shouldn’t really have permission to delete a lot of the system folders. In practice people might give steam superuser permissions so it can fiddle with the system, but doing so is implicitly trusting Valve to not make these kind of mistakes.

  • I’ve been hit by this problem before, about 10 years ago. After reading this, I’m guessing that I installed steam into my “games” folder, and at some point tried to delete something and ended up with all of my games being deleted.

Show more comments

Comments are closed.

Log in to comment on this story!