Saving files is a crap shoot

I lost several hours of work here because my code changes were autosaved gawd-knows-where, and all I have is the file I started from.
I understand you are trying to make an idiot-proof environment, but this idiot has managed to break it somehow, and I don't even know why.
Are these Autosaves going to the Users/Appdata/Temp or something? And maybe deleted when I exited the program?
I can't give any help on what happened, except my working file is hours older than when I last worked on it, and all my changes are gone.
I know it is painful living on the bleeding edge, but I didn't expect it to be like Windows 3.1
Something is seriously wrong if seeming random things happen to users.

Hi @weshowe.

Only when you are working with the file generated via a "New" operation (e.g., selecting File > New from the Arduino IDE menus). These "new" sketches are staged to a temporary folder at a randomized location something like this:

C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved2022217-15832-j1zqcn.9zmlo\sketch_mar17a

You can open the folder by selecting Sketch > Show Sketch Folder from the Arduino IDE menus.

Once you done a "Save as..." operation (e.g., selecting File > Save as... from the Arduino IDE menus), the IDE then writes to that location for all further "Save" operations, whether that is done via an auto save or triggered directly (e.g., selecting File > Save from the Arduino IDE menus).

I think it works fairly well under the following conditions:

  • File > Preferences > Auto save is enabled
  • A "Save as..." operation has been done.

However, there are several known bugs that can cause loss of sketch data under either of the following conditions:

  • File > Preferences > Auto save is disabled
  • A "Save as..." operation has not been done.

I would be very interested in investigating the problem if you are able to provide instructions I can follow to reproduce it. For now, I can share the list of known bugs related to saving:

Please note that the Arduino IDE 2.0.0 release candidates are shared with the community solely in order to offer all interested parties the opportunity to contribute to this free open source project through beta testing and providing feedback.

These "release candidate" versions are not intended to be used for standard development work on your projects. This is a complete rewrite of the Arduino IDE that is under very active development and so you are much more likely to encounter bugs such as the ones with saving sketches.

For normal sketch development work, it is recommended to use the stable Arduino IDE 1.x releases.

I apologize for being irritated.
I always try to make extra saves when I code to other files just so I don't have code losses.
IMO, getting this right is really important, because users are accustomed to the long-standing methods included in such diverse programs as Word and Photoshop.
I shall carry on regardless.

No worries. I know how irritating misbehavior of fundamental functionality like saving can be. It is absolutely essential that this work correctly and intuitively with 100% reliability.

As I mentioned, the developers are already aware of several problems related to saving and these have been carefully documented and tracked. However, it is possible there are other problems that are not yet known. So please keep an eye out for more occurrences of this and let us know if you can determine any related factors.

It is often difficult to know exactly what conditions led to a fault that was encountered incidentally. The instinct is to immediately proceed in trying to recover from the bad state or reproducing it. However, this is a critical moment because you are close to the fault, both in terms of your recollection of the preceding events and in the system state. For this reason, the best thing to do is take a moment to note exactly what was the state of the application, the general environment, and what you were doing before it happened.

There are still some serious problems with saving.

Using:
Version: 2.0.0-rc5-nightly-20220318
Date: 2022-03-18T03:06:27.828Z
CLI Version: 0.21.0 [10107d24]

I start a new sketch by selecting File->New and close the currently open sketch.
A new sketch, named "sketch_mar19a.ino", is started which is fine.
After selecting the processor, copying in a sketch, making some changes, and checking it compiles I select File->Save As.., enter a new name and click Save.
The IDE closes the current sketch, displays a blank screen labeled "index.htlm" showing the spinning wheel and does not recover. I have to eventually close the IDE.
The file does get saved under the new name and re-starting the IDE it actually opens with the newly saved sketch intact.
The above can be reproduced every time.

At least a part of my prior problem with losing work was because I had Auto Save option turned off. It seemed wasteful, as I am slow and deliberate writing code (well, probably everything else, too). But now it is on, and I have no new work loss issues.
That "index.html" issue is present here, also. That complicates using SaveAs to make some intermediate backups under a new name.

Thanks for bringing this to our attention @Willem43! I have submitted a formal bug report to the Arduino IDE developers here:

If you have a GitHub account, you can subscribe to that issue to get notifications of any new developments related to this subject.

I have found that most of the bugs that have potential for sketch data loss or unwanted changes are specific to the "dirty" state that can only be attained by having "Auto save" disabled.

I personally prefer to have control over when my files are saved, so I disable this preference and thus am more likely to be affected by these problems.

Sometimes you have to pick your battles. :slight_smile:
I have spent much time creating habits that used SaveAs to create backup files where I froze code that worked up to some point in my development cycle. I guess lots of pre-alpha versions. They are much easier to revert to or delete than to remake.
I suppose those work habits are what is getting me into trouble. But I see real value in this project once the dust settles. And it works, mostly, quite well. For what I would call core competencies, these SaveAs issues and being careful with them is a small price to pay for the rest of the benefits.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.