jetstack / kube-lego

DEPRECATED: Automatically request certificates for Kubernetes Ingress resources from Let's Encrypt
Apache License 2.0
2.16k stars 267 forks source link

Doesn't build: tar: ngrok: Cannot open: Operation not permitted (Makefile doesn't check if GOPATH is not set) #217

Open ahmetb opened 7 years ago

ahmetb commented 7 years ago

I tried to build it myself with latest commits. I realized this software is trying to install things to my computer (macOS):

which ngrok || curl -sL "https://bin.equinox.io/a/mU8jSiqMekT/ngrok-2.1.14-linux-amd64.tar.gz" | tar xvzf - -C "/bin"

Am I seeing this right? Also why's compiling a go program so complicated?

$ make
rm -rf _test/
rm -rf _build/
mkdir _test/
mkdir _build/
which gocover-cobertura || go get github.com/t-yuki/gocover-cobertura
which: no gocover-cobertura in (/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/usr/local/opt/ncurses/bin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/gnu-tar/libexec/gnubin:/usr/local/opt/gnu-indent/libexec/gnubin:/usr/local/opt/gnu-getopt/libexec/gnubin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/Users/ahmetb/gotools/bin:/usr/local/opt/fzf/bin)
which go2xunit || go get github.com/tebeka/go2xunit
which: no go2xunit in (/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/usr/local/opt/ncurses/bin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/gnu-tar/libexec/gnubin:/usr/local/opt/gnu-indent/libexec/gnubin:/usr/local/opt/gnu-getopt/libexec/gnubin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/Users/ahmetb/gotools/bin:/usr/local/opt/fzf/bin)
which ngrok || curl -sL "https://bin.equinox.io/a/mU8jSiqMekT/ngrok-2.1.14-linux-amd64.tar.gz" | tar xvzf - -C "/bin"
which: no ngrok in (/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/usr/local/opt/ncurses/bin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/gnu-tar/libexec/gnubin:/usr/local/opt/gnu-indent/libexec/gnubin:/usr/local/opt/gnu-getopt/libexec/gnubin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/Users/ahmetb/gotools/bin:/usr/local/opt/fzf/bin)
ngrok
tar: ngrok: Cannot open: Operation not permitted
tar: Exiting with failure status due to previous errors
make: *** [test_prepare] Error 2
ahmetb commented 7 years ago

Turns out it's trying to install to tar xvzf - -C "${GOPATH}/bin" but my GOPATH is not set.

I'm glad you're not doing some sort of rm -rf ${GOPATH}/bin at least. šŸ˜ž

munnerz commented 7 years ago

Thanks for investigating how this came about -

So, since Go 1.8 no longer requires setting a GOPATH, this is something we need to have a think about. As an alternative, we could extract ngrok to a local ./bin directory instead of ${GOPATH}/bin. Previously, if GOPATH wasn't set it would not be possible to build the application at all, hence why this hasn't been a problem in the past.

Am I seeing this right? Also why's compiling a go program so complicated?

Compiling kube-lego can be done using make build. By running make, you are also opting to run all tests. In this case, the kube-lego e2e tests depend upon ngrok in order to test obtaining a certificate.

ahmetb commented 7 years ago

@munnerz maybe we can make make build not depend on the test target. I was able to build it by disabling this.

munnerz commented 7 years ago

Hmm - looking at the Makefile, it appears that's already the case. Are you sure you weren't typing make instead of make build? make will by default call the all target, which does include test (as well as build)

for ref.:

āžœ  kube-lego git:(master) āœ— make build
rm -rf _test/
rm -rf _build/
mkdir _test/
mkdir _build/
echo 0.1.6-dev
0.1.6-dev
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
        -a -tags netgo \
        -o _build/kube-lego-linux-amd64 \
        -ldflags "-X main.AppGitState=dirty -X main.AppGitCommit=47ffbbd755247737b81de22abe6feb849716da00 -X main.AppVersion=0.1.6-dev"
ahmetb commented 7 years ago

My bad. I probably recall incorrectly. Feel free to close or change the title.

geoah commented 6 years ago

Not important enough to warrant its own ticket but relevant to this:

Go supports multiple paths in GOPATH, such as /path1:/path2 which some people use to separate vendor packages (first path) from their own (second path). This seems to be valid according to `go help gopath.

This also breaks the ngrok installation, (which maybe shouldn't be installed automatically, or should not be installed in the go's bin folder.)

/cc @superdecimal