Hi @benoitfl. There was a previous report of this error here (interestingly, also by a Teensy user):
You can try the solution shared by weshowe:
To be more specific, the solution they found was to close all Arduino IDE windows and then delete all the files and subfolders in the folder at the following path:
C:\Users\<username>\AppData\Local\Temp\
(where <username> is your Windows username)
Please be very careful when deleting things from your computer. When in doubt, back up!
If looking for it with your file browser or command line, note that the Appdata folder is hidden by default. On Windows "File Explorer", you can make it visible by opening the "View" menu, then checking the box next to "☐ Hidden items".
You will find that some files or folders can't be deleted because they are in use by some process that is running on your computer. Just skip those. The idea is only to clear out some of the accumulation of temporary files. If some are still left behind in the folder, no problem.
Today I encountered the same problem using IDE version 2.1.0. When I compile the same sketch using IDE version 1.8.19, all is OK.
Deleting the contents of the Temp folder as suggested by weshowe made the problem go away. I still suspect that the new IDE has a flaw...
Compiling the same sketch a couple of times with IDE version 2.1.0 did not show the same problem again.
I do too. BUT... I think it is cause by it not deleting those temp files when a session ends, or else forgetting it had them when it restarts. But I was told this is being worked on, and the workaround is simple, so I carry on, regardless.
It's just interesting that this came out of the blue. I've compiled my sketch rather often (usually after making changes to spot any errors) and have never seen this. Can't reproduce it either after deleting the temp files.
This problem existed in 2.0.4... maybe even before that, but I cannot say so with certainty. I has started a big (for me) project not long after 2.0.4 was released, and I was doing easily 1 to 2 dozen compiles each day (I make a habit of doing that every so often to catch all my misplaced braces and semicolons early).
I remember hitting something like this a few times during the beta process. And having to remove everything from Temp. Later I sort of refined it to only deleting a files with certain name patterns.
But the good thing is, that you have it resolved. now. Hopefully won't hit you again.
I believe there were a few threads/issues associated with stuff left in temp and suggestions on maybe they should add a command like tools->Cleanup which maybe removes all of the detritus that Arduino still leaves behind. like I believe I removed all of the stuff 4 days ago and just checked with the file pattern clangd there are 833 items that match.
Some of which are directories, with lots of stuff in them...
There is a request on github to collect all temporary stuff in one folder so it's easier to cleanout. It has been partially implemented as far as I know.
I also encountered this issue using a Teensy 3.2 in Windows 10 with Arduino IDE 2.1.1.
I don't think the issue is too many temp files, but rather a specific temp file. I am relatively new with the arduinos and I had only compiled like 20 times using a Mega2560 (without encountering any issue). The problem happened after a few times compiling for Teensy (without the card being plugged in). It then somehow went away. I don't remember if I closed/reopened IDE, or restarted my computer, or if it was after I plugged in the card and selected the port, but I certainly did not erase any temp files manually. I was able to successfully compile and download the blink program yesterday. Today, when I tried running the same program, I encountered the error.
In my case, I ran the compiler in verbose mode, and I noticed that it said something like using precompiled file
\AppData\Local\Temp\arduino\sketches\8D3A4DB8B2B82D86809B95DB0A0D069E\pch\arduino.h.gch
so I went and deleted that specific file, and after that IT WORKED!
As a solution, it is certainly easier to erase all the temp files indicated in previous answer, but I'm documenting my error in case it helps pinpoint where the bug is.
Today I received in Win10 and Arduino 2.2.1 & Teensy 4.0 the same message. However: in all users/... temp or arduino/... temp directories were nothing. For me helped delete files in c:\temp directory ( those, who I was able to delete )
But thanks for this thread.
Thank you, worked for my case. I got the dreaded internal error when compiling for a Teensy 3.5.
Curiously the error did not occur when i compiled same sketch for R4 WiFi.