Saving files on Windows only works sometimes

I've run into this issue twice in the past couple of months.

First time it happened, I was modifying an existing sketch, and decided to save the modifications under a new name. I selected "Save as", and used whatever default directory was offered (it was somewhere in AppData). I then quit the IDE, only to discover a few days later that none of my modification were actually saved, and the second file was identical to my starting point. It was a small project, so I didn't dig deeper into what happened, and assumed I must have done something wrong.

After that, I started saving all of my sketches to Desktop (which is backed by OneDrive), so that I could be absolutely sure I knew where my code was.

Yesterday, I once again almost lost an hour of work (Autosave was on, and I was able to recover the file from the Temp directory that I learned about from Saving files is a crap shoot). I used "Save as", and put the new file on my Desktop. I thought it got saved properly, and quit the IDE, but when I came back to it some time later, the file did not have any of my recent changes. After recovering my work from the Temp directory and saving it in a separate text file just in case, I re-opened the IDE, and pasted the code.

That's when I noticed that even if I hit "Save", the circle in the corner of the file tab doesn't go away, so the file is not actually getting saved. I opened the file with Notepad, pasted my code, and tried to save, and Notepad told me that the file is read-only.

I am not sure whether it's some weird interaction with OneDrive, or some other bug, but it seems that "Save as" sometimes results in read-only files, and then the IDE does not show any sort of error when it fails to write to the file.

Hi @bunnycat314

Thanks for your report. I recall there was a previous report of the problem with sketch files having a read-only attribute. I believe they came to the conclusion it was something Windows was doing, not Arduino IDE. Unfortunately I don't remember the exact details and I was unable to find the post despite quite some searching.

If you are able to find a way to consistently reproduce the bug, please let us know. I have never experienced a sketch being given read-only attribute despite years of heavy use of Arduino IDE 2.x, and I don't believe any of the IDE developers have either, so this makes it difficult to work on the problem.

Regardless of whether Arduino IDE or Windows is at fault for setting the attribute, there is no question that Arduino IDE's current behavior of silently failing the save is a bug. That bug is tracked by the 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.

1 Like

I finally found the previous report:

2 Likes

I did find this is quite common.

Here is a link that may help.

1 Like

Thank you, I subscribed to the issue on GitHub.

Thank you!

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