Renaming files results in bogus compile errors (cache not properly cleared) #2323
Closed
3 tasks done
Labels
conclusion: duplicate
Has already been submitted
conclusion: off topic
Off topic for this repository
topic: CLI
Related to Arduino CLI
type: imperfection
Perceived defect in any part of project
Describe the problem
I had an existing sketch that compiled.
I added two new files using New Tab in the IDE, a
.h
and the corresponding.cpp
, and filled them with code.The actual code contained in the files was the intended one with no errors, but I accidentally misnamed the files with the name of a class that already existed in a library.
I attempted to compile and obviously got some errors. One error came from the fact that in the main sketch I was
include
ing the.h
file with the intended name, but such file didn't exist because the file was misnamed. So that quickly made me realize my mistake.So I fixed my mistake by renaming the files.
After that, everything was correct. And yet, the sketch wouldn't compile, giving a bunch of "multiple definitions of..." errors which made no sense whatsoever.
After wasting a lot of time trying to figure out what was wrong (assuming that there still was some wrong name somewhere), and googling the error, it finally occurred to me that maybe there was nothing wrong (now) with the code and this could be the result of some cached previously-compiled code not being removed from the cache.
I restarted Arduino (that didn't help), and then I cleared the cache by manually deleting files in
/tmp/arduino/sketches
and restarted again.After that, and with no further changes to my code, everything compiled.
So, the errors that I had been getting after renaming the files were completely bogus.
To reproduce
I don't have a minimal reproducing sketch, or a non-minimal one that I can share for that matter, but what I did is explained above,.
Expected behavior
One should NEVER, EVER get errors when compiling that are not the result of actual errors currently existing in the code. Cache should be 100% reliable and transparent, meaning the result of compiling a sketch should never differ whether or not I clear the cache. If something in the cache is out of date, it should be invalidated and not used.
Additionally, the IDE should provide a way to clear the cache. Because one can never be sure there isn't some edge case that is not handled correctly. Like this one.
i.e. #419 should be reopened (should never have been closed in the first place)
Arduino IDE version
2.2.1
Operating system
Linux
Operating system version
Manjaro Linux
Additional context
No response
Issue checklist
The text was updated successfully, but these errors were encountered: