arduino / arduino-ide

Arduino IDE 2.x
https://www.arduino.cc/en/software
GNU Affero General Public License v3.0
2.07k stars 353 forks source link

Example files: Save as does not save changes and read only flag is still set on ino file #2421

Closed chemistorge closed 3 weeks ago

chemistorge commented 3 weeks ago

Describe the problem

Arduino IDE, Version 2.2.1, windows 11. The read only flag of Ino file is not removed when using save as: with example files. This results in loss of edits.

To reproduce

Open Example file and edit, Then save as with a new file name. Changes are not saved and the read only flag is set

Expected behavior

Changes to an example file should be saved when using save as.

Arduino IDE version

2.2.1

Operating system

Windows

Operating system version

11

Additional context

I am not able to check nightly builds as this is used with a college environment.


Discussion:

https://forum.arduino.cc/t/sketch-opens-up-read-only/1221298/2

Issue checklist

per1234 commented 3 weeks ago

Thanks for your report @chemistorge.

The root cause of this problem is that read-only permissions have been set on the example files in the filesystem. Since Arduino IDE has a system for preventing unintentional edits to the original example files that doesn't use filesystem permissions in any way, there is no good reason for an example sketch file to have read-only permissions, and thus no reason for us to implement and maintain special handling for such conditions in Arduino IDE (which might be quite complex once you consider that there are an array of file permissions, possibly with different handling from one operating system to another, and that a sketch may contain many different files, with potentially different appropriate handling for certain files e.g., preserving executable permissions on supplemental executables).

So the question in the end is: how did the read-only file permissions get set in the first place? If Arduino IDE did that, then it is indeed our problem to fix. But my hypothesis is that this was actually the result of a rare glitch in the Windows operating system. If so, we really don't have the development resources to implement workarounds for rare bugs in other people's software. For this reason, I think the best way to proceed with the investigation is over on Arduino Forum, where I see you also reported this. I have already started supporting you over there and am only waiting for you to provide the information I requested. If we do eventually determine that Arduino IDE was to blame for the read-only permissions on the original example files, I'll be happy to reopen this bug report.