Open Source

Moving steam's .local folder deletes all user files on Linux

Failing to add a check for an empty variable has left some Steam users on Linux running a recursive delete of their entire filesystem with user privileges.

Symlinking the /home/user/.local/share/Steam directory to a folder residing elsewhere has had a dire impact for a number of Steam users running the software distribution platform on Linux.

No kidding Valve, rm -rf / is scary
No kidding Valve, rm -rf / is scary
(Screenshot: Chris Duckett/TechRepublic)

The issue was first noted on Valve's Steam for Linux GitHub repository, where a user called keyvin moved the directory, then relaunched Steam.

"It reinstalled itself and everything looked great. Until 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," keyvin said.

"This also happened to me a few weeks ago, my entire home was deleted by the script," said another user.

The root cause of the issue appears to be an incorrect empty setting of the STEAMROOT variable that is then passed into an rm -rf command.

# figure out the absolute path to the script being run a bit
# non-obvious, the ${0%/*} pulls the path out of $0, cd's into the
# specified directory, then uses $PWD to figure out where that
# directory lives - and all this in a subshell, so we don't affect
# $PWD
STEAMROOT="$(cd "${0%/*}" && echo $PWD)"
# Scary!
rm -rf "$STEAMROOT/"*

As pointed out in the comments, Valve's bug is reminiscent of a bug in a game called Bumblebee that would delete the entire /usr directory when uninstalled, thanks to a stray space. If you want to see comment carnage in a commit, do read the comments.

In Valve's case, the fix is equally trivial, so it should hopefully be released shortly.

In the meantime, if you are on Linux, do not go symlinking Steam's .local folders this weekend.

About Chris Duckett

Some would say that it is a long way from software engineering to journalism, others would correctly argue that it is a mere 10 metres according to the floor plan.During his first five years with CBS Interactive, Chris started his journalistic advent...

Editor's Picks