Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Moved ~/.local/share/steam. Ran steam. It deleted everything on system owned by user. #3671
Comments
doofy
commented
Jan 15, 2015
|
I am impressed how calm you stay about this. This is terrible. I just lost my home directory. All i did was start steam.sh with STEAM_DEBUG=1. I will investigate this and report back. edit1: I suspect steam.sh got some bugs(does not check own variables) and when it tried to do scary things it crapped himself. edit2: It gets better. Seems on windows Steam is overeager too! https://support.steampowered.com/kb_article.php?ref=9609-OBMP-2526 (The warning part is interesting. Because everybody reads this before uninstalling...) |
Tele42
commented
Jan 15, 2015
|
I agree, that line minimally requires an exists and not null check for $STEAMROOT |
keyvin
commented
Jan 15, 2015
|
#scary! As an ex programmer, that really makes me chuckle. Can I at least get an apology from whoever committed that comment without adding a fix? |
onodera-punpun
commented
Jan 15, 2015
|
This also happened to me a few weeks ago, my entire home was deleted by the steam.sh script. |
pythoneer
commented
Jan 15, 2015
|
introduced here Sep 10, 2013 indrora/steam_latest@21cc141 line 359
but what exactly caused this? i've symlinked ~/.local/share/steam to, so i am a bit afraid to start steam :/ |
TcM1911
commented
Jan 15, 2015
|
pythoneer, I believe the issue starts on line 19:
This probably returns as empty which mean: |
pythoneer
commented
Jan 15, 2015
|
TcM1911, that's my guess, too. |
ghost
commented
Jan 15, 2015
|
@keyvin @d00fy : Did any of you deliberately invoked that script with that option? If yes, why did you do it? What were you trying to achieve? Removing user data is obviously wrong, no doubt about it. But if this happens only when user requests certain action, scope of that issue is somewhat limited. |
jthill
commented
Jan 15, 2015
|
Yeah, they kinda need a readlink in there.
|
jthill
commented
Jan 15, 2015
|
@minio Not "only if". |
soren121
commented
Jan 15, 2015
|
@minio A script accidentally running |
gtmanfred
commented
Jan 15, 2015
|
it is like bumblebee all over again! |
Plaque-fcc
commented
Jan 15, 2015
|
I encountered Steam behaviour like with «--reset» for several times: |
prometheanfire
commented
Jan 15, 2015
|
wonder what the code path is to hit that rm without --reset |
indrora
commented
Jan 15, 2015
|
Can confirm; I have Steam bounded in an SELinux context ("Steam") and SELinux spits out:
Ooops. I'll write a patch and PR it |
johnv-valve
self-assigned this
Jan 15, 2015
|
Does anybody have reliable repro steps for this? I can easily add the checks for STEAMROOT being empty, but I would also like to fix the root cause if possible. |
rcxdude
commented
Jan 15, 2015
|
It will definitely fail if you run steam.sh as |
ayust
commented
Jan 15, 2015
|
Using (For those not familiar, |
ju2wheels
commented
Jan 16, 2015
|
Which is the same thing that would have happened had the unnecessary '/*' not been there anyway, it would have errored out. Its not necessary because the rm was set to recursive already...
|
rcxdude
commented
Jan 16, 2015
|
Here is a patch which enables |
mablae
commented
Jan 16, 2015
|
@rcxdude Come on. We are on github here. Do that in a PR please! Do not post whole patch files into issues... |
dannyfallon
commented
Jan 16, 2015
|
@mablae There is no code on this repo, there is nothing to send in a PR against. A gist wouldn't have gone astray though |
slnovak
commented
Jan 16, 2015
|
@rcxdude: Please link to a Gist. |
sdt16
commented
Jan 16, 2015
Tele42
commented
Jan 16, 2015
|
@johnv-valve regardless of tracking down the cause of this, this rm line must be protected from future accidental gremlins due to the severity of the fail scenario. |
mablae
commented
Jan 16, 2015
|
@dannyfallon Oh, sorry then... |
Wapaca
commented
Jan 16, 2015
|
Does it happen only if you move ~/.local/share/steam ? #scary! :s |
joshenders
commented
Jan 16, 2015
|
The idiomatic way to do this in Bash is to use default variables as in , |
doofy
commented
Jan 16, 2015
|
If steam really wants to act like a package manager it should only delete files created by itself. @soren121 +1 |
ryenus
commented
Jan 16, 2015
|
Shell scripts can also have tests, see shunit2. I wish I used it instead of making mini/naive one myself. |
damm
commented
Jan 16, 2015
|
it's 2015; I think we can do better than complex badly written shell scripts.
|
mpnordland
commented
Jan 16, 2015
|
@d00fy Steam is essentially a package manager for your games. |
carlosmcevilly
commented
Jan 16, 2015
|
@ju2wheels your snippet has a spurious 'D' in it, 'STEAMROOT' versus 'STEAMDROOT' -- so ${STEAMDROOT} will be empty and that code is going to end up starting at the current directory and doing a recursive delete from there. Could be almost as bad depending what the current directory is. Let's hope nobody copy/pastes that snippet for actual use. |
soren121
commented
Jan 16, 2015
|
@mpnordland I think that's what he said. |
neko
commented
Jan 16, 2015
|
Is this the new bumblebee? |
nhuerta
commented
Jan 16, 2015
|
I hope no one is running this as root |
hakusaro
commented
Jan 16, 2015
|
@d00fy I'm going to make the argument that while Steam is certainly at fault, you should definitely be using off site backups for this exact reason. |
DanielGibson
commented
Jan 16, 2015
On a typical desktop Linux system that would only make it marginally worse - reinstalling the OS is less of a problem than losing all your data from $HOME |
keyvin
commented
Jan 16, 2015
|
@john-valve You are more than welcome to any log files that a data recovery service can get from the drive, as long as you give me a copy of everything. I do not have a large drive to undelete to, so the data that wasn't in the cloud is. Mad props for #Scary though @nicatronTg Yes, I should need to have a complete back up rotation of dailies, four weeklies, and 12 monthlies so that I can feel safe and secure running steam for linux. |
nhuerta
commented
Jan 16, 2015
|
@DanielGibson Sure, as long as you didn't mount other partitions rw somewhere else |
ju2wheels
commented
Jan 16, 2015
|
@carlosmcevilly even if they did it would be better than the existing code thats there ;-) , it will just fail and not take the world with it. But.... but... i fixed my typo ;-) , thx. |
RamchandraApte
commented
Jan 16, 2015
|
Hmm.. when I was copying .steam from an older installation to a newer installation of Kubuntu, I saw in stdout messages like "running rm -rf " when I was running it (after the @keyvin This is somewhat OT but to recovery your data, immediately stop using the external drive and run something like PhotoRec or TestDisk or if the drive has important files you can even use a program like ddrescue to copy the drive. If you haven't used the drive since the data loss then most of your data should be recoverable. |
pixelb
commented
Jan 16, 2015
|
Note there is also protection against this within GNU rm itself. I.E. this would have protected the / dir at least:
But it's best leave out the / in any case as it's redundant
|
seanchannel
commented
Jan 16, 2015
|
Bash-isms are the problem here:
If |
hachre
commented
Jan 16, 2015
|
My condolences, @keyvin. I lost all my data like this in 1998 due to a SuSE Linux installation script having exactly this bug in it as well. Back then I lost my Linux, my Windows, and all my data and I only learned what backups are really for from that incident... |
michaelsbradleyjr
commented
Jan 16, 2015
|
@TcM1911 Determining the path of the script being invoked, in a fully portable (w.r.t. platforms) and completely reliable manner, even in the face of symlinks, is a tricky problem and all too easy to get wrong. The only bullet proof way of doing it, of which I'm aware, is provided below (assumes bash); could be prepended to any script needing this functionality.
|
|
@sindresorhus I'd disagree with using trash instead of rm because having to rely on node just adds complexity to systems that wouldn't otherwise need node. It's also worth mentioning that most of the linux distros I've used recently have the --preserve-root flag already available... |
tute
referenced this issue
in coreyleveen/super-pry.io
Jan 16, 2015
Merged
Add warning note about security risks #1
sindresorhus
commented
Jan 16, 2015
I know people disagree with that. That's fine. I was linking to the |
paranoidsp
commented
Jan 16, 2015
|
I've moved my directory and symlinked it too, and I've thankfully not had such issues before. Regardless, as someone mentioned before, I'd strongly suggest adding test cases against such major bugs. |
albertvaka
commented
Jan 16, 2015
|
This big companies are so in the need of engineers that would even hire my grandma, and then shit happens. |
Strubbl
commented
Jan 16, 2015
|
In this context, how can i remove steam from my Linux without using steam? |
skybert
commented
Jan 16, 2015
|
As @d00fy said, it's amazing how calm you were about this, @keyvin. A great bug report it was too. Embarrassing as bugs like these are, it's a lot easier to take it on with reports like this one. As others have pointed out too, this is an excellent bug for advocating using some BASH-strictness, I like to use this:
This bug is also a good case for advocating TDD with shunit2. Make the steam script modular so that parts of it can be (unit) tested, write a test for this bug which fails and then fix it. We all do this in other "real" programming languages and there's no reason why we can't do this in BASH too. Hooking it up with CI servers like Jenkins is no problem either. |
darklajid
commented
Jan 16, 2015
|
Tangentially related: I assume all the people that moved this folder are running out of disk space/want to stuff the files elsewhere. Like myself. This is what I did on Windows just a couple days ago, I'd hope that Steam on Linux supports the same (hidden) option: http://www.rockpapershotgun.com/2012/09/11/finally-an-in-built-way-to-choose-steam-install-locations/ Basically:
Now you can pick the location during installation ("This game? Install to my SSD. That? Ah, large slow disk is fine"). You can also move games between locations (from $path1/SteamApps/common to $path2/SteamApps/common and that will 'just work' in nearly all cases). So, maybe Valve should make that more accessible in the UI, bypassing the need of users to mess with the default install path? |
lodyb
commented
Jan 16, 2015
|
Thanks for reminding me to always check shell scripts before executing them |
synapse84
commented
Jan 16, 2015
|
@darklajid changing the destination can already be done without using -dev, console, and install_folder_ui. steam -> settings -> downloads -> steam library folders |
darklajid
commented
Jan 16, 2015
|
@synapse84 Whoa - and here I kept that bookmark around, treasuring my knowledge of hidden options. :) Thanks a lot! |
This was referenced Jan 26, 2015
dsohler
commented
Feb 10, 2015
|
Solution: Just don’t delete user data. Ever. |
This was referenced Feb 13, 2015
aaronfranke
commented
Mar 10, 2017
|
Has this issue not been fixed yet? If it has been fixed, it should be closed. If it is not fixed, it needs more attention. |
|
Yes, the issue that is tracked in this issue report was resolved. |
kisak-valve
closed this
Mar 10, 2017
soredake
referenced this issue
in lutris/lutris
May 9, 2017
Closed
Allow arguments in prefix command. #564
referenced
this issue
in hamishcoleman/thinkpad-ec
Jun 22, 2017
added a commit
to KellerFuchs/admin-tools
that referenced
this issue
Aug 29, 2017
KellerFuchs
referenced this issue
in hashbang/admin-tools
Aug 29, 2017
Merged
ansible.cfg: Error-out on undefined variables #81
craig-sanders
commented
Sep 12, 2017
•
|
kisak-valve said that this is resolved. It's not, the "fix" doesn't do anywhere near enough sanity checking for a script that has the potential to delete the user's files. Here's what I consider to be the absolute minimum level of sanity checking required: (This script was written by me and is hereby placed in the public domain, or the 2-clause BSD license if you are in a jurisdiction that does not acknowledge "public domain". Do whatever you want with it, no royalties or any form of compensation or acknowledgement is expected or required, even the BSD license requirement to include a copyright notice is waived. I renounce all rights to this trivial code)
If I save this as
Exactly what it's supposed to do. If I copy it to
Again, exactly what it's supposed to do. And, thanks to
|
arno01
commented
Oct 5, 2017
|
You are always welcomed to use a containerized Steam (no performance impact) in case you afraid it can damage anything on your system, except the Steam-related files itself of course -- |
dsohler
commented
Oct 5, 2017
|
Always put Steam in a 32 bit chroot in order to run it on a recent system (64 bits of course). Only game devs want 32 bit nowadays so a chroot is necessary anyways if you don't want to clutter your system with a shitload of multiarch stuff. If you prevent steam from deleting all your data that's a bonus, too. |
mhalano
commented
Oct 5, 2017
|
In fact containers and chroot are very secure, but isn't the best option from user's POV. An application which sane scripts which doesn't delete all your files still is the best option. May be one day when Flatpak and Snap become a standard we can rethink this. |
Germano0
commented
Oct 9, 2017
Source? |
dsohler
commented
Oct 9, 2017
Yes, of course. But as long as the software needs 32 bit libs I'm not going to run it outside a chroot/container/whatever. I don't want to clutter my system with multiarch crap. |
polkovnikov-ph
commented
Oct 9, 2017
•
No surprise. Most of players on Windows are kids, most of players on Linux are programmers. Also these are "bug reports" and not "support requests". |
Bengt
commented
Oct 9, 2017
Yeah, it is really a big problem for content creators to have an engaged audience. /s |
ryanpcmcquen
commented
Oct 9, 2017
|
@ohjames, but it could. There isn't a lot of finality either way without more data. These users could be finding valid bugs, in which case they are doing the developers a service. |
dsohler
commented
Oct 10, 2017
Bug reports aren't support requests. |
polkovnikov-ph
commented
Oct 11, 2017
|
So some random guy said "An engaged audience does not equate to a large number of support requests" twice but I have no idea why this truism is being repeatedly asserted? |
kon14
commented
Oct 11, 2017
•
@ohjames He's just treating you with your own medicine. But I guess now that you deleted your comments people can't actually support any of this, right? In any case, this is all off-topic, isn't that so? |
simi
commented
Oct 11, 2017
|
@kisak-valve please can you lock this? It's getting really off-topic here. |
ryanpcmcquen
commented
Oct 11, 2017
|
@simi, the issue is closed, but not fixed as well as it should be. Locking it is going to keep the issue from being re-opened and actually resolved. |
|
I'd rather not lock issue reports if I don't need to. At this point, I'd need either a test case that causes this issue or a request from a Steam dev to re-open this issue. Since there is over a hundred participants on this issue report, I'd like to see at least 25 thumbs up on @simi's request to lock this issue. |
mhalano
commented
Oct 11, 2017
|
If Valve properly fix the problem (is not that hard) the off-topic messages go away. |
ryanpcmcquen
commented
Oct 11, 2017
|
@kisak-valve, @craig-sanders has shown a fix here: #3671 (comment) |
hasufell
commented
Oct 11, 2017
•
Sorry, but none of you really understand the problem. The problem is not the lack of arbitrary sanity-checks, the problem is that recursive deletion is an inherently problematic operation, especially if it is non-interactive. That is also why no package manager out there will ever do |
simi
commented
Oct 11, 2017
|
@kisak-valve issue was marked as closed (and by your comment also as resolved) and it is here just for annoying offtopic discussion. I don't see any reason to keep it unlocked and keep offtopic discussion. I would like to stay watching this issue, but I don't care about offtopic. Once there will be news, you can:
and interested people will get notification. |
h1z1
commented
Oct 12, 2017
|
I don't know if they enjoy the publicity and free labor or what but Valve will never fix problems like this, seriously there are many threads like it on github alone. Looking at steam.sh should make anyone cry in a corner. There are lovely assumptions like this all over the place:
That is so wrong on so many levels but they've hardcoded things everywhere. I can only imagine what the Windows client is like. This one just boggles my mind:
Look around those lines and cry. The RUNTIME_DEBUG_URL is based on a grep with no error checking. Isn't even over SSL. Rather hilarious thing is they explicitly force http1.0 in download_archive anyway. My point is there are so many places this bug can surface it's no wonder Valve are unable to fix it. I wouldn't personally go near a LAN with steam running. |
dsohler
commented
Oct 12, 2017
|
Conclusion: They have absolutely no idea how to develop software for Linux-based operating systems. |
hasufell
commented
Oct 12, 2017
That is correct. And it's not even so much about the poor quality shell scripting. They don't use the opensource community to their benefit. They have no understanding of the ecosystem or the community. There are lots of people out there that would rewrite their scripts for free and even collaborate on linux-specific steam code. Apart from the tons of suggestions here, there have also been numerous PRs about making the scripts POSIX compatible and whatnot. They have been ignored. Linux is basically a platform where you get reviews, suggestions, code and even professional help for free. Except valve doesn't use it. That's not really a problem of "oh, I let my grandma write the bash scripts that handle safe user data removal", it's your huge ignorance of the specificities of a platform and its community. Something went wrong during your "linux agenda". |
polkovnikov-ph
commented
Oct 12, 2017
|
But it totally makes sense given the way Valve works internally. There was employee or a group that made the project, but now they are either not interested in it or not even employed anymore. Who will merge PRs, if nobody knows the code? |
craig-sanders
commented
Oct 14, 2017
|
@hasufell yes, keeping track of all files and deleting only known files when uninstalling is what a package manager should do. Steam doesn't do that, and likely never will. Steam isn't a real package manager. It's a game library manager originally written for an OS where package management is an alien concept, where each program is installed by running its own installer program (and assumes it's the only program that will ever run on the system so can do whatever TF it wants to without caring about screwing up other software the user may have installed)....For all its flaws, Steam on windows is actually a great leap forward compared to that even if it does seem primitive and broken compared to standard practice on linux or mac. Hell, even on Linux you still get idiot devs telling users to ignore the package manager and just run Anyway, as always, it's more useful to deal with things as they are, not as they would be in an ideal world. Without the magic ability to make steam work like a real package manager, having a bunch of paranoid sanity checks in front of anything that affects file deletion is the most useful thing to do....equalled only by:
These mistakes and newbie errors are just what I've noticed from a casual glance at the script. There are undoubtedly many more. |
aaronfranke
commented
Oct 15, 2017
Many Linux distros store it in /usr/bin instead, along with everything else that usually goes in /bin. |
hasufell
commented
Oct 15, 2017
You missed the point. It isn't actually that hard for a program to keep track of all the files it will output in a given directory. Even programs on windows are able to do that sort of thing. No one said steam should become a package manager. It should just be able to clean up after itself and while it is updating. |
craig-sanders
commented
Oct 15, 2017
|
@aaronfranke really? name these "many distros". in fact, name one. bash has been in /bin on linux forever because that's where system-native shells belong. third-party shells tend to go in /usr/local/bin. or in some bizarre location like /usr/opt/local/where/the/fuck/is/it on solaris. @hasufell no, i didn't miss your point. you missed mine, which is that wasting time complaining about the fact that steam isn't a real package manager and doesn't behave like one is completely pointless and useless. Deal with things as they are, not as they should be and not as you wish they were. Steam is what it is, and there's a limit to what and how much can be fixed or improved. |
hasufell
commented
Oct 15, 2017
No, that's not what I said. Package managers are orthogonal to the point I made, which suggests you actually didn't understand the point.
That is just wild guessing. Why would it not be possible to fix the behavior as explained? I don't see any technical limit there. Please explain what "limit" that would be. |
craig-sanders
commented
Oct 15, 2017
|
you may think you were making some significant point, but really you were just wishing that steam was a real package manager. It isn't, and no amount of bitching about it is ever going to get Valve to devote the time and resources to make it one. There's little or no benefit to them in doing so - steam mostly functions well enough at what it is, a games library manager. as for your "wild guessing" comment and request for an explanation of the limit - we're talking here about the steam.sh shell script, which is a wrapper around the steam application, doing environment setup and other things (like helpfully deleting all user files on certain error conditions). Rewriting the steam app so that it acts like a package manager should is way beyond the scope of fixing the obvious errors in a shell script. I would have thought that was obvious. In case you hadn't noticed, Valve don't even acknowledge the fact that their crappy steam.sh script is still broken and puts user files at risk - there's some small hope that they might eventually do that and adopt some of the ideas and suggestions in this thread (there's some evidence they've already done that for some things), but there's no way they'll ever re-write the steam app to incorporate the basic features of a package manager. |
hasufell
commented
Oct 15, 2017
•
Again, no.
No, we are talking about steam as a whole.
Again, no. This is not about package managers. You seem to have no understanding of how the proposed technology works. This is not about fixing half-assed shell scripts, which are already by concept wrong. This is about correctness, which is crucial when you deal with user files. Recursive deletion is never correct from an automated cleanup POV. Recursive deletion is something a user may trigger, based on his needs.
First, there is no rewriting of the "steam app" involved. Second, that's guessing again. |
aaronfranke
commented
Oct 15, 2017
|
https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/ Solaris started it, Fedora was one of the first Linux distros to do it. |
mittwinter
commented
Oct 15, 2017
@craig-sanders: Sorry to barge in, but maybe you have to update your knowledge on this one:
And probably others already, as this merge of /bin to /usr/bin was advocated by systemd, so probably many other distros that switched to systemd will eventually follow. |
dsohler
commented
Oct 15, 2017
ju2wheels
commented
Oct 15, 2017
|
Guys, we are bike shedding solving a problem which has already had a suitable solution presented and alternatives. Discussing it ad nauseam isnt going to make Valve come out and fix it if they have no interest, we have suitably voiced opinion here. Lets post a link to some other forum (Reddit, Google groups, or elsewhere) and take the sidebar discussion there. |
mittwinter
commented
Oct 15, 2017
This may be true so far, but every backwards compatibility will eventually be going away.
is certainly outdated advice for any software maintained currently or in the future. Distributions will have to do enough patching for legacy software once such backwards compatibility is faded out. |
polkovnikov-ph
commented
Oct 16, 2017
|
@ju2wheels But a Half Life 3 talk didn't even have a chance to start! |
irvingpop
referenced this issue
in habitat-sh/core-plans
Nov 22, 2017
Open
Update postgresql to latest and enable it to run without root permissions #980
user15177
commented
Nov 28, 2017
|
Has this problem been fixed? I really want to play the metro series, but this scares the crap out of me. |
dsohler
commented
Nov 28, 2017
|
@user15177 Set up a chroot for Steam and run it from there so it can do no harm to your actual system. |
alphapapa
commented
Jan 1, 2018
|
@craig-sanders Since you posted some cleaned-up code from the script and some good Bash scripting advice, a note: Always use the |

keyvin commentedJan 14, 2015
Edit: Please stop posting stupid image memes or unhelpful messages. This interferes with Valve's ability to sift through the noise and see if anyone can figure out what triggers it.
This may not be a common problem because I change all sorts of configuration about my system. The script in question does something in a really, really stupid way, but it probably doesn't trigger the fail scenario for every system because...
Original Bug:
I am not sure what happened. I moved the folder in the title to a drive mounted under /media/user/BLAH and symlinked /home/user/.local/steam to the new location.
I launched steam. It did not launch, it offered to let me browse, and still could not find it when I pointed to the new location. Steam crashed. I restarted it.
It re-installed 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.
Everything important, for the most part, was in the cloud. It is a huge hassle, but it is not a disaster. If there is the chance that moving your steam folder can result in recursively deleting everything in the directory tree you should probably just throw up an error instead of trying to point to other stuff. Or you know, allow the user to pick an install directory initially like on windows.
My system is ubuntu 14.04, and the drive I moved it to was ntfs if its worth anything.