Can't save sketches, file returns to original

New user, been playing around with some tutorials and working on a couple projects. Had an issue a week back where my sketch didn't save, but assumed I did something wrong and moved on. I spent a bunch of time working on a sketch last night based on a sketch I picked up online for a scoreboard. I saved periodically, at least 6-7 times. Got my sketch working, did a final save, and wanted to add IR input so I save_as with a new suffix to start working on it and called it a night a bit later. Opened up today and none of my work was saved again, including all the work before adding the IR. The folder that holds the file with new suffix is timestamped correct, but the file is from several days ago - the date I downloaded the original file.

I started all over tonight, made my edits and saved with a new suffix. Just checked the file and it's still from 3 days ago (folder is timestamped correct). Is this some basic user error I'm missing? It seems like computer 101, I can't understand why a save_as wouldn't save my file.

Hi @black_dow.

Which operating system are you using (e.g., "Windows")?

Which version of Arduino IDE are you using (e.g., "2.0.1")? The version is shown on the window title bar and also in the Help > About dialog.

I ask for this information because I want to give you the appropriate instructions for the operating system and IDE version you are using.

Thanks for the response. I'm using Windows 11. I'll have to get back with the version, I don't have that computer in front of me. But I just downloaded it a couple weeks ago so it should be a relatively current version [EDIT: it's Version 2.1.1].

It seems like a really odd issue, that isn't really Arduino as much as Windows. Especially because I have done several sketches and they saved fine, but this isn't the first time this has happened.

One other abnormality I noticed. Was that two days ago, when I was working on the sketch that didn't save, my mouse cursor (using trackpad) was really laggy. There was an obvious delay in initial movement and it would overshoot my target. I know, the more I type this out the more it sounds like a Windows issue, but it's nothing I've ever experienced on that laptop outside of using Arduino. Just thought I'd check here to see if it's some obvious user error that I'm missing. Thanks again.

Thanks for the information. I'm going to ask you to post some additional information that might help us to identify the problem.

Please do this:

  1. Select File > Quit from the Arduino IDE menus if it is running.
  2. Start Windows "File Explorer".
  3. Open the Arduino IDE installation folder.
    The default installation location is at one of the following paths:
    • C:\Program Files\Arduino IDE
      
    • C:\Users\<username>\AppData\Local\Programs\Arduino IDE
      
      (where <username> is your Windows username)
      :exclamation: If looking for it with your file manager or command line, note that the AppData folder is hidden by default. On Windows "File Explorer", you can make it visible by opening the "View" menu, then checking the box next to "☐ Hidden items".
  4. In the folder listing of the Arduino IDE installation folder, hold the Shift key while clicking the right hand button on the mouse.
  5. From the context menu, click "Open PowerShell window here".
    Windows PowerShell will now open with the current directory set to the Arduino IDE installation folder.
  6. Type the following command:
    & ".\Arduino IDE"
    
  7. Press the Enter key.
    Debug output should now be printed to the PowerShell window as Arduino IDE starts.
  8. Wait for Arduino IDE to finish starting.
  9. Open the problematic sketch.
  10. Make any change to the sketch.
  11. Select File > Save As... from the Arduino IDE menus.
  12. Save the sketch to any name and location you like.
  13. Switch back to the PowerShell window.
  14. Right click on the title bar of the PowerShell window.
    This will open a context menu.
  15. Select Edit > Select All from the context menu.
    This will select all the text in the PowerShell window.
  16. Press Ctrl+C.
    This will copy the contents of the PowerShell window to the clipboard.
  17. Open a forum reply here by clicking the Reply button.
  18. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code tags icon on toolbar
  19. Press Ctrl+V.
    This will paste the output into the code block.
  20. Move the cursor outside of the code block markup before you add any additional text to your reply.
  21. Click the Reply button to post the output.

Please let me know if you have any questions or problems while following those instructions.

Hey, thanks for the response and the detailed walkthrough. Everything was easy to follow.

But I'll save you reading through some code. Turns out it was user error. I noted in your walkthrough you said to "open the problematic sketch"; I was thinking it was an IDE issue, but your comment made me think it might be the sketch itself so I opened a few and found some save, some don't. The ones that don't save were example sketches I D/L, not ones I wrote myself. So sure enough, "read only" was checked. I feel pretty dumb for missing that, but in any other program it'll tell me the file is R.O., there was no indication here and it let me close out the unsaved file as if I had saved it. Is that working properly? Any reminders to help prevent doing that in the future?

Thanks again.

Nice work on tracking down the cause of the problem! Thanks for taking the time to post an update with your solution. I'm sure the others who later find this while researching for information about a similar problem will be very grateful.

I had suspected the sketches having read-only file attributes was the cause, but I don't like to operate on assumptions when I am providing support so I wanted to wait to get confirmation from the logs.

Something to note is that Arduino IDE doesn't set a read-only attribute on files. It will prevent you from editing established files in some cases where that would be potentially harmful with a tooltip that says:

Cannot edit in read-only editor

but "read-only" in that sentence only means that the editor itself is in a state that does not permit changing the file, even though there is no such restriction at the file system level.

No. The correct behavior would be for Arduino IDE to clearly communicate about the problem to the user, as you expect. The Arduino IDE developers are tracking this here:

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

image

1 Like

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