IDE 2 not saving in the same location where it was opened

I have had to stop using the IDE 2. Several times I have found that when the sketch is compiled it is not saving it in the same location in which the sketch is opened. I have my sketches on a windows shared drive. I open a sketch from the shared drive make some changes then compile and upload the sketch into a board everything seems fine however the changes are saved in the local mydocuments/arduino directory not the shared drive in which it is opened. It does not do this all the time. It only seems to happen when it causes me the most aggravation and a 2 hour drive to go back and get the right version of the sketch. I can't pinpoint when it happens but it does on a regular basis. I don't think I am doing anything to cause this behavior it does not happen with the old ide. Now that I know it happens I can check and verify but sometimes I get comfortable and forget. I hope it can get resolved.

Hi @frankbicknell. Thanks for your report.

Is there something specific that gives you the impression the problem is correlated to compiling?

What procedure are you using to save the sketch? There are three ways to save a sketch in Arduino IDE 2.x:

  • Auto save: if the "Auto save" checkbox is checked in the preferences, Arduino IDE automatically saves the sketch after every change.
  • File > Save (or the equivalent keyboard shortcut): this saves the sketch in place.
  • File > Save As... (or the equivalent keyboard shortcut): this saves the sketch to the location you specify in the dialog.

I would not recommend it to a beginner with Arduino, but I get the impression you are fairly advanced. My suggestion is to start using Git for version control of any significant sketch project. This will surely prevent any chance of lost work in this manner because after every significant change to the sketch, you will make a "commit" of that change to the repository. If the code is not being saved to the expected location, you will immediately notice this because there won't be any changes to commit when you attempt to do it.

This is only one of the many significant benefits of using a professional quality version control system.

I have always relied on the sketch getting saved a the time of the compile with earlier versions of the IDE. I can't recall ever having to manually save a sketch except to change it's saved location. However if I do use 'save as' in the IDE 2 app the default directory is always the local drive and directory not the one it was opened in. That is different from the IDE 1.8. I have not had a chance to experiment with file 'save'.

Here is an old adage for you. 'Can't teach an old dog new tricks.' I have been doing it this way for over 35yrs. I have developed a few bad habits in software development but I am able to manage them well. I don't know github I am sure I can do it but for my purpose I don't feel that I need that level of structure but thanks for the suggestion.

Anyhow I can continue with the 1.8 version for now and revisit 2.0 IDE at a later date.

The behavior of automatically saving when a compile or upload is started is specific to Arduino IDE 1.x. But the Arduino IDE 2.x "Auto save" feature is equivalent. The only real difference is it saves constantly rather than only on the specific arbitrary event of a compile.

That is understandable. It is not for everyone.

I would like to clarify something though. I actually recommended Git, not GitHub. Git is a free open source version control software. GitHub is a website where you can host your Git repositories.

Even though GitHub is a convenient service, there is no direct connection between Git and GitHub. You can use Git completely locally without ever uploading your repository to a cloud service like GitHub. Or if you did want to put it on a cloud service you could choose one of the alternatives, or you could host it on your own server.

That is understandable. If you decide to give Arduino IDE 2.x another try and still have this problem, please let us know and we'll see if we can investigate it further.

4 posts were split to a new topic: "Save As..." dialog defaults to sketchbook root instead of previous folder

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