manifoldco / torus-cli

A secure, shared workspace for secrets
https://www.torus.sh
BSD 3-Clause "New" or "Revised" License
613 stars 32 forks source link

Permission issues when building from source #380

Open mattroseman opened 6 years ago

mattroseman commented 6 years ago

Steps to reproduce

  1. Reinstall Go, making the GOROOT /usr/local/go directory
  2. Clone the torus-cli repo into the normal place in $GOPATH/src/github.com/manifoldco/torus-cli
  3. Run make bootstrap
  4. Run make binary

This is the output I get after step 4.

CGO_ENABLED=0 go build -i -v -o torus -ldflags='-X github.com/manifoldco/torus-cli/config.Version=0.30.1' github.com/manifoldco/torus-cli
go build net: open /usr/local/go/pkg/linux_amd64/net.a: permission denied
make: *** [Makefile:77: binary] Error 1

Now if I play around with the command the make file is running CGO_ENABLED=0 go build -i -v -o torus -ldflags='-X github.com/manifoldco/torus-cli/config.Version=0.30.1' github.com/manifoldco/torus-cli The error isn't thrown if CGO_ENABLED is set to 1, or if -i is removed. Not sure if that is useful information, or not.

Also, since this is a permission issue, I tried running sudo make binary. I get this

CGO_ENABLED=0 go build -i -v -o torus -ldflags='-X github.com/manifoldco/torus-cli/config.Version=0.30.1' github.com/manifoldco/torus-cli
can't load package: package github.com/manifoldco/torus-cli: cannot find package "github.com/manifoldco/torus-cli" in any of:
    /usr/local/go/src/github.com/manifoldco/torus-cli (from $GOROOT)
    /root/go/src/github.com/manifoldco/torus-cli (from $GOPATH)
make: *** [Makefile:77: binary] Error 1

It seems if I try and build with the permissions I need to write to /usr/local/go, I lose the environment variables pointing to my GOPATH.

Finally, if I install go at ~/go instead of /usr/local/go, then I have write permissions when I build, and don't have any issues.

So while I did find a solution that let me build the code, IDK if it is required to build torus-cli as a user that has write permissions in GOROOT or not.