I was working in Arduino IDE 2.3.2 last night and got tired so I left the IDE Open with my sketch. When I got back to the IDE today I noticed the sketch tab is gone. Image Below. Windows 10 Pro PC/Laptop.
The sketch is no longer there. I was using the IDE with Teensy but I've had this problem before regardless of microcontroller. I use CCleaner Professional to clean up files and have it set to clean automatically, I am "Assuming" CCleaner is the culprit and I may need to add some Arduino IDE folders/files to my exclusion list within CCleaners Options. Does/did anyone have a similar issue or is this a completely different issue.
Regardless, just to be safe, is there a list of folder/files I can tell CCleaner to stay away from on Windows 10 Pro installations. I think the app is cleaning a cache folder the IDE may use. I know a few locations Arduino IDE uses but I don't have a full list I can tell CCleaner not to touch.
I think you are right. When you create a sketch via File > New, Arduino IDE stages the sketch files under the system temporary folder. The Arduino IDE editor automatically syncs any external changes that are made to those files, so if the temporary folder is cleared then it also clears the staged sketch from the Arduino IDE editor.
where <username> is your Windows username and <differentiator> is some randomish text that makes each folder name unique. So if CCleaner allows configuring exclusions using patterns (e.g., regular expressions, globs) instead of only explicit paths then you can simply configure the pattern to exclude anything path with the static initial part C:\Users\<username>\AppData\Local\Temp\.arduinoIDE-unsaved.
Compilation Cache
When you compile a sketch, Arduino IDE saves the compiled board core and libraries to a cache. It will then reuse the cached objects during subsequent compilations for that board unless the core or library source code has changed (e.g., you updated the boards platform or library to a newer version).
This is useful because it reduces the time it takes to compile sketches. Even though CCleaner deleting the compilation cache won't cause any significant problems, since Arduino IDE should just do a full compilation if it doesn't find a cache, the cache is useful so I suggest you also exclude it in the CCleaner settings.
Fortunately in this case the configuration will be easier because they are stored under dedicated parent folders:
CCleaner has advanced options in the Professional/Paid version that allow saving CCleaner options to an INI file. This is required for the following to work by editing the .ini file.
In CCleaner navigate to "Options" "Advanced" and select the save to .ini option, make sure it is checked/enabled.
Exit CCleaner completely
Open a text editor as Administrator then open file and select (on windows):
C:\Program Files\CCleaner\ccleaner.ini
Scroll all the way to the end and add the following lines (change USERNAME with your user name for each line if necessary):
You can also add entries one by one in the CCleaner "Options"/"Exclude" area. More information on the use of these INI files options with CCleaner is on the CCleaner help/howto page:
CCleaner can use wild cards in file names and folders so this should work fine. There may be additional paths that Arduino IDE uses. Mine seem to be in Arduino15 folders because of upgrades but A PC that has never had Arduino IDE installed may actually us "Arduino" or "ArduinoIDE".
I haven't been able to test if this prevents the error from the first post, I will see tonight.
Yes, but I would be very surprised if CCleaner messed with the files under those paths. That would be very harmful behavior.
Automatically clearing files from the system temporary folder is more reasonable (though I personally I don't see the need for such a thing and would never use a program like CCleaner on my own system).