Linux Gaming News

Moving Steam of Linux local folder deletes all files

linking_steam_local_folder_deletes_user_files

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.

The good news here is that the bug does not happen randomly and would require you to actually be a semi power Linux user of a sort to trigger it. Which only happens when you try to move the Steam directory, located at ~/.local/share/Steam by default, somewhere else, like on a more spacious storage device, and then try to symlink (like “creatng a shortcut using ln -s”) it to the original location. This seems to trigger Steam’s automatic integrity detection which, in turn, triggers its reset mechanism and, along the way, will try to delete everything. User TcM1911 seems to have traced the root cause (no pun intended) in the snippet of code below.

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 steam.sh 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.

steam_for_linux_file_deletion_issue

Due to symlinking, the variable $STEAMROOT ends up as blank, so that later on the command “rm -rf $STEAMROOT/” will actually just read as “rm -rf /”. Any seasoned Linux user will tell you how dangerous that command is, which is basically like deleting all the contents of your C: drive on Windows. Fortunately, thanks to how Linux works, it can only delete the files owned by the user, which means that the OS itself remains untouched and functional. That doesn’t save the user’s own files though, and any external storage attached to the computer at that time will also be effected.

The problem is somewhat easy enough to fix by simply checking whether or not $STEAMROOT is empty or invalid before proceeding with the command. Variations of that idea have been suggested in Valve’s Github account, but Valve has yet to chime in on the issue.

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, for all you Linux gamers, do not go symlinking Steam’s .local folders this weekend.

”linux-game-gaming-gamer-news”

You Might Also Like

%d bloggers like this: