Arduinio IDE automatically loading external file changes

This feature is a REAL PAIN in the back side sometimes.

I can result in one losing all file edits inadvertently.

It would be better if the IDE asked you if you wanted to load external file changes and gave you the option to say no - do not load them.

I use that feature all the time. I checked "Use External Editor" in preferences, and any changes made in the external editor are automatically loaded. If you’re not using this feature, you’ll need to stick to just the Arduino IDE and avoid external editors.

Hint: Do not have more than one .ino file in the sketch folder. The IDE will combine them, which can lead to confusion and drive you bonkers.

Having it ask to load each external file individually would be a real pain. Instead, it automatically loads all the selected header files, the associated .cpp files, and several other files that help define the specific Arduino board you're using. These files vary between different Arduino models.

I use Geany as my external editor and keep most of the library files in the sketch folder, as I often modify them. This approach prevents issues when libraries are updated. It’s not uncommon for me to have a dozen or more files open as I work on a project. Keeping library files local also lets me review their content, see how to call their functions, and understand what they return.

Note that this is only present in the Arduino IDE 1.x preferences. Arduino IDE 2.x always picks up external changes to sketch files that are in a saved state, without requiring the user to first enable this behavior via a preference.

That I did not know as I have not switched to the 2.x IDEs. Thanks

"Having it ask to load each external file individually would be a real pain. "
Why can't it be an option in preferences!
Use or don't use it - your choice.

I have the opposite problem. It never loads the external changes, and is constantly asking me if I want to overwrite the externally changed files. Since I'm editing files in two different IDEs, I want Arduino to pick up those changes. I can't find a pref to adjust this behavior.

So what is the sequence/scenario where you actually lose edits?

Was this from using the IDE and an external editor?
If so, you really should only be editing/modifying the file in one place.
either in the IDE or in an external editor.

For temporary changes, just use an external editor, and undo the changes if you don't like them before you finally exit the editor.

--- bill

It would be nice if they gave you the option in settings.

And they could always give you a list of changed files with check boxes you can click indicating which ones you are happy to re-load.

Hi @jetforme.

It will only load the external changes if the sketch is in a saved state.

You can ensure it is always in a saved state by enabling the "Auto save" preference. The IDE will then save the sketch automatically whenever you made any edits via the Arduino IDE editor. Of course this setting significantly changes the behavior of Arduino IDE, so you should make sure to consider whether this is something you want, and to adjust your workflow as needed.

When mine stops loading external changes, I have to close all IDE windows and restart it, then it works again for a while.

Hi @m_elias. Do you have the "Auto save" preference enabled?

In case you aren't sure how to check whether it is enabled, I'll provide instructions:

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Look to see whether the checkbox next to the "Auto save" preference in the dialog is checked or unchecked.
  3. Click the "CANCEL" button.
    The "Preferences" dialog will close.

It will never load the external changes if the sketch is a library example sketch opened through the menu down in the examples for a library.
This is a different behavior from IDE 1.x

--- bill


This 2.x behavior change can create some confusion due to it creating unexpected behaviors. It also makes it kind of PITA for a library developer to use the Arduino 2.x IDE for library development of the library examples.
There is a work around. Which is open the sketch from the "open" menu rather than through the examples menu.
I really abhor nanny modes.
And in this case I still strongly believe that the 2.x developers got it wrong.
I think always loading in any external file changes and a simple warning when attempting to change/save a library example through the IDE would have been better and much simpler to implement.
The current nanny mode for library examples can be confusing due to its inconsistent behaviors between library example sketches and non library sketches.

This is why I still primarily use Arduino IDE 1.x when doing development work on my Arduino libraries.

I don't see an option to change it on IDE 2. Like it said, mine works again after a full IDE restart.

Please try following my instructions again. The instructions I provided are applicable to Arduino IDE 2.x.

You should definitely see the "Auto save" option in the Arduino IDE 2.x Preferences dialog if you follow the instructions correctly:

My apologies, I misread your post thinking you were talking about a Load External Change option. I do have the Auto Save option and mine is turned off. Is that option anything different then me clicking Save occasionally?

Thanks for the clarification.

The only difference is that you might forget to click save.

As I mentioned earlier in the thread, Arduino IDE 2.x only loads external changes if the sketch is in a saved state. The "Auto save" feature is relevant because, when enabled, it ensures the sketch is always in the saved state and thus we don't need to consider an unsaved state as a possible cause of external changes not being loaded.

When you restart Arduino IDE, the sketch will be in a saved state. So my hypothesis was that the "stops loading external changes" behavior you encountered might have occurred under the following conditions:

  • "Auto save" preference is disabled
  • Changes were made to the sketch in the Arduino IDE editor since the last time it was saved.

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