go run or
go mod tidy with this error message.
There might be not $HOME environment.
In my case, it occurred when I tried to use
runcmd of cloud-init.
echo $HOME // nothing is displayed
Must set $HOME environment before execute