"Error compiling for Board..."

Hello
This is for Arduino 1.8.15 on MXLINUX
I have a problem compiling for the board "ESP32 DEVKITV1" If I chose "ESP32 Dev Module" if I compile my code it loads and works a expected. If I modify the code it reports "Error compiling for board ESP32 Dev Module" . I then change to "DOIT ESP32 DEVKITV1" and it compiles and works. If I then modify the code it now reports "Error compiling for board DOIT ESP32 Devkitv1"... The result is that I have to tell Arduino to flipflop between these two boards each time I compile.

Welcome to the forum

Your topic has been moved to the Programming Questions category of the forum

Please post your sketch, using code tags when you do. This prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

Please enable verbose output during compilation and compile your sketch. Please post the full error message using code tags (use e.g. the <CODE/> button).

Are you running a 32-bit linux OS or 64-bit?.
Which version of the ESP32 board package are you using?

If there are no obvious error messages, please post your sketch as well (see post above).

[edit]
I would also like to know which computer hardware you're using
[/edit]

Different code will have different compilation chains and environments on different boards. So it needs to be judged by the specifics of the error, can you post your detailed code?

panic: runtime error: index out of range [6] with length 6

goroutine 1 [running]:
arduino.cc/builder.(*includeCache).Next(...)
arduino.cc/builder/container_find_includes.go:209
arduino.cc/builder.findIncludesUntilDone(0xc00003ac00, 0xc0008c5ef0, 0x569be0, 0xc0008ee1e0, 0xc000a04acb, 0x6, 0x0, 0x0)
arduino.cc/builder/container_find_includes.go:321 +0x152d
arduino.cc/builder.(*ContainerFindIncludes).Run(0x6bc690, 0xc00003ac00, 0x41bc3c3c, 0x0)
arduino.cc/builder/container_find_includes.go:149 +0x69b
arduino.cc/builder.runCommands(0xc00003ac00, 0xc000b1dc48, 0x22, 0x22, 0xc000047b01, 0x203000, 0x203000)
arduino.cc/builder/builder.go:191 +0xe3
arduino.cc/builder.(*Builder).Run(0xc000047eb8, 0xc00003ac00, 0x7ffc21ac7b37, 0x46)
arduino.cc/builder/builder.go:124 +0x969
arduino.cc/builder.RunBuilder(...)
arduino.cc/builder/builder.go:222
main.main()
arduino.cc/arduino-builder/main.go:338 +0x64d
arduino-builder returned 2
Error compiling for board ESP32 Dev Module.

Does the problem persist when you close and open the IDE?
Can you please answer the below

Lastly

Can you start the IDE from the shell and compile for the "ESP32 DEVKITV1". Copy and paste the output here; it might shine some light on the problem.

Do you have the option to upgrade to IDE 1.8.19. There was a known issues (long ago) but I can't find for which IDE version; see e.g. [SOLVED} Upload Problems with Firebeetle ESP32-E - #2 by ptillisch (and more search results: arduino-builder index out of range - Google Search).

Linux 64 bit MXLINUX 21.3
uname= Linux lkj12 6.0.0-10.1-liquorix-amd64 #1 ZEN SMP PREEMPT_DYNAMIC liquorix 6.0-6~mx21+1 (2022-11-30) x86_64 GNU/Linux
Board=EPS32 DEVKIT1
Board packages= Arduino ESP32 Boards V 2.0.17 and ESP32 by Expressive Systems V3.0.4
My PC hardware is a lenovo x270

Sorry, forgot to ask for the sketch; can you please post it. Please don't forget to use code tags.

Looking at the error message it looks like some array is out of length?