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:
opened 11:18PM - 19 Jun 16 UTC
topic: code
type: imperfection
topic: build-process
### Describe the problem
The previous file persists in the sketch build folder … after a sketch code file with extension other than `.ino`/`.pde` is renamed.
🐛 This can result in spurious compilation errors or confusing bugs. Arduino CLI users can work around the bug by adding the `--clean` flag to their command, but the only workaround for Arduino IDE users is to manually clean the build folder.
### To reproduce
```text
$ arduino-cli version
arduino-cli.exe Version: git-snapshot Commit: a735ddfd Date: 2023-01-15T01:00:07Z
$ arduino-cli sketch new /tmp/FooSketch
$ echo "void asdf() {}" > /tmp/FooSketch/foo.cpp
$ arduino-cli compile --fqbn arduino:avr:uno /tmp/FooSketch
[...]
$ mv /tmp/FooSketch/foo.cpp /tmp/FooSketch/bar.cpp
$ arduino-cli compile --fqbn arduino:avr:uno /tmp/FooSketch
C:\Users\per\AppData\Local\Temp\arduino\sketch-2405C4C9F90028537C79B0744BCE536E\sketch\foo.cpp.o (symbol from plugin): In function `asdf()':
(.text+0x0): multiple definition of `asdf()'
C:\Users\per\AppData\Local\Temp\arduino\sketch-2405C4C9F90028537C79B0744BCE536E\sketch\bar.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
Used platform Version Path
arduino:avr 1.8.6 C:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Error during build: exit status 1
$ ls "C:/Users/per/AppData/Local/Temp/arduino/sketch-2405C4C9F90028537C79B0744BCE536E/sketch"
bar.cpp bar.cpp.d bar.cpp.o foo.cpp foo.cpp.d foo.cpp.o FooSketch.ino.cpp FooSketch.ino.cpp.d FooSketch.ino.cpp.o
```
🐛 `foo.cpp` is still present in the build folder even though not present in the sketch. `foo.cpp` is compiled in addition to `bar.cpp` and the primary sketch file.
### Expected behavior
Files are always removed from the sketch build folder when no longer present in the sketch.
### Arduino CLI version
#### Original report
Arduino IDE 1.6.9
#### Last verified with
0.34.1
### Operating system
- Linux
- Windows
### Operating system version
- Mint
- 10
### Additional context
#### Workaround
<a name="workaround-cli"></a>
##### Arduino CLI users
Run an `arduino-cli compile` command with [the `--clean` flag](https://arduino.github.io/arduino-cli/dev/commands/arduino-cli_compile/#options).
<a name="workaround-ide"></a>
##### Arduino IDE users
1. Examine the compiler error message. It will show the path of the temporary build folder.
For example, in this error:
```text
C:\Users\per\AppData\Local\Temp\arduino\sketches\7930E8409AED6D4F4A4782CF985194E9\sketch\foo.cpp.o (symbol from plugin): In function `asdf()':
(.text+0x0): multiple definition of `asdf()'
C:\Users\per\AppData\Local\Temp\arduino\sketches\7930E8409AED6D4F4A4782CF985194E9\sketch\bar.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
```
The temporary build folder is:
```text
C:\Users\per\AppData\Local\Temp\arduino\sketches\7930E8409AED6D4F4A4782CF985194E9\sketch\
```
1. Delete the temporary build folder.
#### Additional reports
- https://github.com/arduino/arduino-cli/issues/1699
- https://github.com/arduino/arduino-cli/issues/2058
- https://github.com/arduino/arduino-cli/issues/2613
- https://github.com/arduino/arduino-cli/issues/2870
- https://github.com/arduino/arduino-ide/issues/970
- https://github.com/arduino/arduino-ide/issues/1316
- https://github.com/arduino/arduino-ide/issues/1691
- https://github.com/arduino/arduino-ide/issues/2323
- https://github.com/arduino/arduino-ide/issues/482#issuecomment-2188269824
- https://github.com/arduino/Arduino/issues/2072
- https://forum.arduino.cc/t/ide-and-compiler-clear/1077526
- https://forum.arduino.cc/t/changed-tab-name-in-sketch-still-linking-old-o-file/1046286
- https://forum.arduino.cc/t/weird-error-pointing-to-old-code/1113608
- https://forum.arduino.cc/t/ide2-bit-upset-need-help/1129513
- https://forum.arduino.cc/t/renamed-tabs-wont-go-away/1165338
- https://forum.arduino.cc/t/file-renaming-issue/1173234/6
- https://forum.arduino.cc/t/reorganizing-code-w-wire-h-library/1180211
- https://forum.arduino.cc/t/ide-not-recognising-file-type-change-from-c-to-cpp/1215993
- https://forum.arduino.cc/t/code-compiles-in-old-ide-but-not-the-new-one/1286767
- https://forum.arduino.cc/t/problem-while-defining-namespaces-with-it-own-cpp-and-hpp-files/1304403
- https://forum.arduino.cc/t/there-is-a-bug-in-the-wire-library-for-version-1-8-6-avr-boards/1336297/18
- https://forum.arduino.cc/t/new-version-of-arduino-ide-2-3-5-error/1371224/20
- https://forum.arduino.cc/t/how-to-clear-cache-from-ide/1374114
---
<details>
<summary><b>Keywords</b></summary>
<p>
- rename
- header
- .h
- .cpp
- .c
- C++
</p>
</details>
### Issue checklist
- [X] I searched for previous reports in [the issue tracker](https://github.com/arduino/arduino-ide/issues?q=)
- [X] I verified the problem still occurs when using the latest [nightly build](https://www.arduino.cc/en/software#nightly-builds)
- [X] My report contains all necessary details
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:
macos
Or if you don't normally want to see them, use the Command +Shift +. keyboard shortcut to toggle the visibility.
1 Like
kenb4
April 17, 2025, 12:32am
6
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
kenb4
April 17, 2025, 6:57am
11
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