manifoldco / manifoldco/torus-cli

Permission issues when building from source

Open
#380 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
603
Forks
30
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Makefile target at line 77 and reproduce the make bootstrap followed by make binary flow using the reported Go installation locations. Compare the failing go build command with the variants that omit -i or enable CGO, and verify whether the build works without elevated privileges while preserving GOPATH; done means the source build has a documented or corrected behavior for this setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.