Whilst reviewing a colleague's documentation, where he was describing how to code in Go, I noticed a discrepancy in the way that things work when one runs a command as a non-root user vs. running as root, via Super User Do ( sudo )
Having downloaded / unpacked Go thusly: -
sudo wget -c https://golang.org/dl/go1.16.6.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
resulting in Go being installed in /usr/local/go with the actual go binary being in /usr/local/go/bin
ls -al /usr/local/go/bin
drwxr-xr-x 2 root root 4096 Jul 12 20:04 .
drwxr-xr-x 10 root root 4096 Jul 12 20:01 ..
-rwxr-xr-x 1 root root 14072999 Jul 12 20:04 go
-rwxr-xr-x 1 root root 3453176 Jul 12 20:04 gofmt
we needed to run a build ( of containerd ) as root, via sudo make and sudo make install
However, this failed: -
cd ~/containerd
sudo make
+ bin/ctr
/bin/sh: 1: go: not found
make: *** [Makefile:219: bin/ctr] Error 127
as I'd previously added it to my PATH via this line in ~/.profile : -
This totally helped: -
bash profile works for user but not sudo
specifically the answer that had me validate the PATH in both cases: -
echo 'echo $PATH' | sh
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin
echo 'echo $PATH' | sh
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin
echo 'echo $PATH' | sudo sh
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin
+ bin/containerd
+ bin/containerd-stress
+ bin/containerd-shim
+ bin/containerd-shim-runc-v1
+ bin/containerd-shim-runc-v2
+ binaries
Also, make me a sandwich .....
No comments:
Post a Comment