"make: go: command not found" - although go binary is in $PATH

7.6k views Asked by At

I want to build runC on a Raspbian GNU/Linux 10 (buster), Linux 4.19.97-v7+.

I downloaded the go1.15.6 ARMv6 version, extracted it to /usr/local and updated $PATH & $GOPATH.

go version returns

go version go1.15.6 linux/arm

and echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin

Following the instructions for building runC, running sudo make install returns

make: go: command not found
install -D -m0755 runc /usr/local/sbin/runc

Why doesn't it find the go binary?

2

There are 2 answers

1
Volker On

make has its own PATH. Consult make‘s documentation.

1
John On

As far as I'm aware, sudo runs the program as the root user, not your current user. As such, it may be the case where the $PATH obtained by the Makefile is not the same as it is on your current user.

To fix this, you could run sudo -E make install, where -E ensures that your environment is preserved.