How to clear cache from IDE?

Is there a way to delete the cache folder from the IDE, or to tell the IDE to not reuse the cached files? (I searched the forum and couldn't find one mentioned)

I've connected the dots to realize if I use the IDE to rename some of my .h or .cpp files then often subsequent compilations will fail as they try to use outdated .o files with the old file names. Restarting the IDE is not sufficient to resolve the problem, but removing the cache folder works every time. That's not quite as simple as it seems because the cache folder is in the hidden Libraries folder on macOS.

So is there a way to tell the IDE to not reuse the cached files or to clear/delete them?

This happens with at least the last several IDE versions including 2.3.6. I'm on macOS 15.3.2

All you need to do is save the sketch you are working on. I think that bug was fixed in 2.3.6, but I'm not sure.

I have AutoSave ON and I'm already using IDE 2.3.6.

Are you suggesting doing a manual Save is sufficient or does it need a SaveAs and change the whole sketch name to force a full recompile?

In any case quitting the IDE (which doesn't prompt for unsaved changes) and restarting it does not resolve the problem.

Sounds like a different problem. Are you using any cloud service like Microsoft OneDrive?

Hi @JoeHuber.

It sounds like you are encountering this bug:

No. You should manually delete the sketch build folder as a workaround for the bug.

It sounds like you already know how to do that, but in case you are having trouble, just let us know and we'll provide instructions.

If you like, you can configure macOS to always show the Library folders:

Or if you don't normally want to see them, use the Command+Shift+. keyboard shortcut to toggle the visibility.

1 Like

Not for me

$ find /private/var/folders -name sketches 2> /dev/null
/private/var/folders/rf/_lcbkycs7pld4c0vk5xd53sr0000gn/T/arduino/sketches

There's a bunch of "random" folders in there, one for each sketch

$ ls `find /private/var/folders -name sketches 2> /dev/null`
05E5D45AD298268AAA0E1289BF14EE92	5FD30D51257B44B002F369D1669BFB5C
09DDC5CF5807552D331FA74AD299483C	65EC76FA6DE1D2C4DCFDAED308E36DA1
0C757DD9781FE76541E17D3E7ED7D774	731AE8136766C03FF4877A6BFDDB9162
2118DF32DE8E78472CA613BA8C84EA85	88C15829197E78D9A90CF881EE15FB1A

You could erase all of them. To find the one specific to your sketch, turn on "Show verbose output during compile" and the full path is mentioned often.

1 Like

Interesting... here's the path to mine...
/Users/joehuber/Library/Caches/arduino/sketches/EF5D6A677F7367EE163D5E3D79923CF2/sketch/src/FileTools.cpp.o

And when the problem occurs I can remedy it by deleting:
/Users/joehuber/Library/Caches/arduino/sketches

Yes, that sounds like the same issue.

Is there a recommended way to rename .h and .cpp files to avoid triggering this bug? I'm going to try quitting the IDE entirely and using the Finder to rename them and then start the IDE again. Fingers crossed...

The only way you could avoid it would be to also rename the sketch (or otherwise change its path) when you renamed the files, which would cause a new build folder to be used.

Per Thanks for the info. I guess I'll just automate deleting the cache folder for those cases where I want to rename files...

Thanks,
Joe

arduino-cli v1.1.0 includes "Fixed build_cache.path behaviour" which moved the path from a temp directory to the platform-specific cache directory, as returned by os.UserCacheDir

That is first picked up in IDE v2.3.4 which upgraded CLI from v1.0.4 to v1.1.1

I'm still running 2.3.3 on this Mac.

2 Likes

I'm have a similar problem. Sounds like the IDE should be modified to included a "Rebuild Solution" like Visual Studio has under the build tab that rebuilds the sketch from scratch.
How do you get this recommendation into the IDE change queue?

Hi @reddogluna. It would be silly to add a cache clearing feature to Arduino IDE as a user unfriendly workaround for a bug. The correct use of the limited development resources is to fix the bug.

I agree that a bug should be fixed but there maybe conditions that would not be considered a bug that could cause a problem.
It's interesting Microsoft felt that having a "clean build" vs. just build was worth adding another button.

Again, How do you get this recommendation into the IDE change queue request and let the "team" decide

Microsoft has a lot more resources than the Arduino company.

I am the most senior and active member of the team who maintains the Arduino IDE project. So the team has already decided and you would only waste your time by submitting a formal request.

1 Like