Sublime Forum

Help! Sublime ate my code

#1

Hey there! I am very new to Sublime and coding in general, so keep that in mind with my descriptions and technical knowledge. Also, I apologize in advance for the novel but I’m trying to be as detailed as possible!

I have been using Sublime Text on my Mac for about 6 weeks while learning the basics of coding in a class. I have had no issues thus far. Yesterday, I was working on a style sheet (titled style.css) and checking out my changes in real time via web browser. I’ve always hit the save shortcut after every new word or line - I’m just nervous like that. Everything was working just fine and I had added several new sections of code that were new concepts to me, so I don’t remember them off the top of my head but had saved everything several times so wasn’t worried. I stopped working but kept Sublime open in my dock. A couple hours later I opened up the sublime window to keep working. My code all looked fine, and after I added a new line and hit save, there was an error saying that sublime couldn’t save. I tested out several lines and confirmed it wasn’t an issue with my code, Sublime wouldn’t save ANY changes. I wish I took a screenshot of the error message! Anyways I had saved my work from earlier so I didn’t think anything of just closing the window and re-opening my file from finder. When I re-opened the file, it was completely blank. All the code was gone. There were no recovered files. What the heck?! I restarted my computer thinking that might help and allow me to see recovered files, but when it restarted Sublime Text had dissapeared from my dock and my applications folder! I had to reinstall it. Another very weird and frustrating thing.

I tried googling around but couldn’t find anyone with my exact issue. My course instructors also don’t have much advice on recovering my pervious saved file. I am hoping that someone here might know a way… :frowning:

Thanks for you time!

0 Likes

#2

Off the top of my head, the first thing that comea to mind for suddenly not being able to save a file (which would also dovetail with file content going missing) would be having files opened on a shared network drive or mounted disk that was unmounted (or the share somehow disconnected).

In such a case the window would still show you the old content of the file, but it would be marked as dirty (if you have that option turned on) because it can’t be found on disk any longer, and attempts to save such a file would fail because it would try to save in the (now) unmounted location.

It’s also possible that something in the interim changed the directory permissions on the directory the files are contained in, but in that case it would also have to have done some serious changes for you to not be able to see the files at all.

This sounds suspiciously like you double clicked the dmg file that the MacOS version of Sublime is distributed as and then ran it directly from the resulting mounted disk image instead of copying Sublime Text.app to e.g. your Applications folder.

This works (Sublime keeps its configuration in your home directory no matter where you run it from) but once you unmount the disk image (which happens automatically when you reboot), the location the app was in is no longer there, which would explain why it seemed to dissapear.

Possibly the two problems may be related; you may have been saving your code onto the mounted disk image, so if you remounted it you might find your files in there. On the other hand I don’t think MacOS will let you unmount a disk image that’s currently in use, and it seems like it would be if you had it still running at the time, so this may be a longshot.

2 Likes