Using W10, Arduino 1.8.13, with a Mega2560.
My code compiles fine the first time, then further attempts get the message
"Error compiling for board Arduino Mega or Mega 2560." I have to close the IDE and restart to compile or upload again.
I saw a few threads from 2018 that indicated OneDrive was the problem and would be fixed in the next version. But 2 years later I'm seeing it.
I moved the project out of OneDrive, but I still get this error. I also saw a thread about turning off
"Aggressively Cache Compiled Core", which I couldn't find. I did find "compiler.cache_core" and turned it off, but no change.