Second time I compile a sketch I get this error "panic: runtime error: index out of range [5] with length 5"

556 Views Asked by At

I am using Arduino IDE version 1.8.13 on A raspberry PI using raspberry Pi OS 64 bit.

I am building code for an ESP32.

If I edit my script, ( and I get the same error using different scripts ) and upload it, the next time I compile and upload I get the following errors.

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

goroutine 1 [running]:
arduino.cc/builder.(*includeCache).Next(...)
    arduino.cc/builder/container_find_includes.go:209
arduino.cc/builder.findIncludesUntilDone(0x4000080400, 0x40002427b0, 0x15bd40, 0x4000aa1ef0, 0x40002ac115, 0x8, 0x0, 0x0)
    arduino.cc/builder/container_find_includes.go:321 +0x103c
arduino.cc/builder.(*ContainerFindIncludes).Run(0x2b9608, 0x4000080400, 0x41bc3c3c, 0x0)
    arduino.cc/builder/container_find_includes.go:149 +0x4cc
arduino.cc/builder.runCommands(0x4000080400, 0x40004dfc38, 0x22, 0x22, 0x7f00000001, 0x400, 0x400)
    arduino.cc/builder/builder.go:191 +0xcc
arduino.cc/builder.(*Builder).Run(0x4000093ea8, 0x4000080400, 0x7fe51762bc, 0x34)
    arduino.cc/builder/builder.go:124 +0x7f0
arduino.cc/builder.RunBuilder(...)
    arduino.cc/builder/builder.go:222
main.main()
    arduino.cc/arduino-builder/main.go:338 +0x624
arduino-builder returned 2
Error compiling for board ESP32 Dev Module.

If I edit the script, save it and then re-open it, the script will upload. I should say I tend to have another script open in a window, so I save and close the script I am working on, and use the other window to use File=>Open recent to re-open the script. The problem only occurs when it has successfully compiled.

I have used Arduino on a Pi for a couple of years and never had this problem before, it is only recently the problem has occurred.

Has anyone got any ideas how I can investigate further or maybe fix the issue. It is annoying more than anything else.

Steve

PS I have had to add some tags, hope i have used applicable ones

2

There are 2 best solutions below

2
Luka Lafaye de Micheaux On

I had the same problem and fixed it by completely removing my Arduino software before installing the latest Arduino version.

For a clean install : run rm -rf ~/.arduino15 && rm -rf ~/Arduino # Arduino installation folder and get the latest release at https://www.arduino.cc/en/software

If you would like to keep your current Arduino version, I suggest you look into the following threads:

According to the threads, a temporary fix is to delete /tmp/arduino/sketches/.../includes.cache before each second compilation. You could automate that using a bash script.

0
Dominic Cerisano On

There is something wrong with the apt repo install for adruino, which is version 1. It always produces that error. However, I find that version 2 is still not stable on Linux.

Fortunately there is a solution.

  1. sudo apt purge arduino
  2. download the last version 1 installer for linux from adruino.
  3. Extract it (as sudo) to /opt
  4. Run the install.sh script (as sudo)

This does all the things, including creating a desktop app icon. Does not have that stupid error. Also the default build warning level is somewhat verbose, you can set it to none in preferences.