Error when compiling latest Marlin 3d printing firmware

I uploaded hundreds of times the Marlin firmware to my Arduino Mega board with no problems. But in this year they released the 2.x version and I am having a hard time to upload it to my Arduino Mega board using ARDUINO IDE. I already reported this issue on GITHUB but they told me “Arduino IDE is buggy, use PlatformIO/VSCODE”. However installing platform io and vscode uses lots of space, install tons of unnecessary things.

So I would like to keep using Arduino IDE. When I try to compile the project I see these messages below. How can I solve it?

....
....
"sketch\\src\\sd\\usb_flashdrive\\lib-uhs2\\usbhost.cpp.o" "libraries\\LiquidCrystal\\LiquidCrystal.cpp.o" "core\\core.a" "-LC:\\Users\\PC\\AppData\\Local\\Temp\\arduino_build_428456" -lm
avr-gcc: error: CreateProcess: No such file or directory
Using library LiquidCrystal at version 1.0.7 in folder: Z:\Desktop\COPIE SOMENTE O ATALHO - arduino\libraries\LiquidCrystal 
exit status 1
Error compiling for board Arduino Mega or Mega 2560.

As you probably learned already, the issue is caused by the hundreds of files in the Marlin sketch causing the compilation command to exceed the Windows maximum path length of 32767 characters.

I'm happy to tell you that Arduino has made a fix for this issue. There hasn't been a production release of the Arduino IDE since that time, but the fix should be in the hourly build of the Arduino IDE, which you can get from the downloads page: https://www.arduino.cc/en/software#hourly-builds Please give that a try and let me know if you have any more problems.

I'll also mention that the same fix is in the production release of Arduino CLI.

If you are looking for a solution for working with Arduino sketches that doesn't use a lot of disk space and doesn't install anything unnecessary, this is a great solution. Arduino CLI is the Arduino's official command line tool, consisting of a single executable file less than 22 MB. The Arduino IDE is much larger than that because it also contains all the GUI code that is not needed for a command line tool.

https://arduino.github.io/arduino-cli/latest/installation/

@pert I cant believe you helped me! I wasted all this day trying lots of "fixes", like creating a temp directory and assign it inside the preferences file, and lots of other things that had zero result. However, after I try downloading the nightly version (1.8.14), it worked perfectly! I didnt try the CLI suggestion but the version with GUI worked nicely.

THANK YOU SO MUCH!!!

Sketch uses 124796 bytes (49%) of program storage space. Maximum is 253952 bytes. Global variables use 4176 bytes (50%) of dynamic memory, leaving 4016 bytes for local variables. Maximum is 8192 bytes.

I'm so glad to hear this!

I think you're the very first person to try out this fix in the Arduino IDE (it has been extensively tested in Arduino CLI, but the integration into Arduino IDE happened only a matter of hours ago).

This was a very tricky issue that the Arduino developers partially fixed a couple times in the past by finding ways to shorten the commands a bit, but it kept coming back as more and more files were added to Marlin. So this time around, they made a big effort to find a solution that will always keep the command under the maximum length. So hopefully it's fixed for good this time.

@pert I am glad this fix happened cause I had already gave up on using VSCODE and PLATFORM IO (too complex, too much installs to just upload a sketch).

What is amazing is that the 1.9.x version of Marlin would compile and upload to my Arduino Mega in less than 30 seconds, however the Marlin 2.x version took almost 6 minutes to compile and upload. But at the end, it worked perfectly!!!

Thank you so much for your attention!