arduino-cli panic: runtime error: invalid memory address or nil pointer dereference - Go

Bug Report

Current behavior

I am trying to create a docker image with arduino-cli but with the command:

RUN arduino-cli lib update-index

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0xa8 pc=0x7318bf]

goroutine 1 [running]:, {0xe4f074, 0x19}, {0x0, 0x0, 0x0}) /go/pkg/mod/ +0x5f /go/pkg/mod/{0xe4f074, 0xc00030b810}, {0x0, 0xc000340ed0, 0x15b9948}) /go/pkg/mod/ +0x45 /go/pkg/mod/ +0xc6

Expected behavior

INFO[0000] Using config file: /root/.arduino15/arduino-cli.yaml INFO[0000] arduino-cli version 0.0.0-git [...]


  • CLI version (output of arduino-cli version): arduino-cli alpha Version: 0.0.0-git Commit: Date:
  • OS and platform: Ubuntu 20.04.2 LTS (Focal Fossa)

Additional context

Image builds fine on another server Ubuntu 20.04.1 LTS (Focal Fossa)

Asked Oct 21 '21 02:10
avatar Goral64

5 Answer:

RUN go install

Thank you. This change helped. The image is built without errors.

Answered Aug 31 '21 at 09:38
avatar  of Goral64

I can see the problem here:


Arduino CLI uses The dependency is pinned to that version. Did you do something like this?:

go get

Minimal demonstration of the issue:

package main

import (

func main() {

It seems that we will need to make this change when the time comes to update to the new version:

NewPo should always be used to instantiate a new Po object

--- a/i18n/locale.go
+++ b/i18n/locale.go
@@ -32,7 +32,7 @@ var (

 func init() {
-       po = new(gotext.Po)
+       po = gotext.NewPo()

 func initRiceBox() {
@@ -79,6 +79,6 @@ func findMatchingLocale(locale string, supportedLocales []string) string {

 func setLocale(locale string) {
        poFile := box.MustBytes(locale + ".po")
-       po = new(gotext.Po)
+       po = gotext.NewPo()
Answered Aug 31 '21 at 03:24
avatar  of per1234

Did you make some custom modifications and built the Arduino CLI yourself? The version output is not the one I'd expect from one of our builds.

Answered Aug 31 '21 at 07:53
avatar  of silvanocerza

My Dockerfile:

# Stage 1 of 2
FROM golang:latest
RUN go get -u

# Stage 2 of 2
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

COPY --from=0 /go/bin/arduino-cli /usr/bin/arduino-cli
ADD cli-config.yml /root/.arduino15/arduino-cli.yaml

# arduino
RUN apt-get update \
    && apt-get install -yy --no-install-recommends arduino \
    && apt-get -y autoremove \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN arduino-cli lib update-index \
        &&arduino-cli lib install \
        "Adafruit BME280 Library" \
        "Adafruit Si7021 Library" \
        "Adafruit Unified Sensor" \
        "ClosedCube SHT31D" \
        "DallasTemperature" \
        "DHT sensor library" \
        "DoubleResetDetector" \
        "HLW8012" \
        "OneWire" \ 
        && arduino-cli core update-index \ 
        && arduino-cli core install esp8266:esp8266 \
        && arduino-cli core install esp32:esp32

COPY script/ /
RUN chmod 755 /

CMD ["/"]

My cli-config.yml file


I didn't change anything in the arduino-cli code

Answered Aug 31 '21 at 08:17
avatar  of Goral64
RUN go get -u

This line might be the issue, go help get says this:

The -u flag instructs get to update modules providing dependencies of packages named on the command line to use newer minor or patch releases when available.

Try changing it to:

RUN go install
Answered Aug 31 '21 at 08:25
avatar  of silvanocerza