Confused on Sketch Book Location

Why doesn't the Sketch Book Location in Preferences reflect where the current project is first saved, but, instead, is attached to the last project opened. I am using IDE version 2.3.6.

For example, I open the IDE to an old sketch, then I use File->New Sketch to open a new sketch. I save the new sketch in a new folder, but the Sketch Book Location in Preferences is still pointing to the old sketch. Why doesn't the new sketch automatically update the Sketch Book Location? Is there a setting in the IDE that I am missing?

I have used other IDEs that take care of project location bookkeeping automatically.

You are confusing the location of an individual sketch when saved, with the overall sketchbook location

The sketchbook location in Preferences is a folder where sketches are saved. Each sketch in the sketchbook folder has its own folder within which are the files belonging to that sketch

1 Like

Adding to above

A sketch can be saved anywhere.

One thing about the sketchbook directory is that it does not only contains sketches but also all 3rd party libraries that you have installed.

When I work on a hardware/software project (or any project), I think in terms of a project folder. In a project folder, I have folders for all the code, the schematics, the pcb layouts, the data sheets for that project, the libraries, etc. It is very foreign to me to think about a folder with all sketches from all projects separate from the individual project folders. This is the first IDE (Java, HTML, Python, C, C++, Kicad, etc.) that I have used that uses the paradigm that all code for all projects is kept in one folder.

I have been tripped up several times when I open a sketch in a different project, and the Preferences Location is still pointing to the value from the previous sketch. I end up with libraries in the wrong place and non-sketch files (.h, .cpp) in the wrong place. A real pain to unravel. Just call me old-school.

Does the Arduino IDE have the concept of a project as I think of it, or am I using the wrong IDE?

That is not how it works in the Arduino IDE either. The sketchbook folder provides a default location for folders for each sketch but you can put your sketch and any supporting files in a location of your choice if you want. Think of that as your project folder if it suits you.

The only limitation is that the folder name must match that of the principal .ino file of the project

Incidentally, the Preferences Sketchbook location does not change unless you do it manually