carlosedp / cluster-monitoring

Cluster monitoring stack for clusters based on Prometheus Operator
MIT License
740 stars 200 forks source link

Getting `/bin/jb: not found` when I try running `make vendor` #36

Closed geerlingguy closed 4 years ago

geerlingguy commented 4 years ago

When I try running make vendor after customizing my vars.jsonnet file, I keep getting:

$ make vendor
Installing jsonnet-bundler
rm -rf vendor
``/bin/jb install
/bin/sh: 1: /bin/jb: not found
make: *** [Makefile:26: vendor] Error 127

It seems like the path /bin/jb is hardcoded, but when it installs jsonnet-bundler it is running with my local GOPATH, which is ~/go, so jb is installed in ~/go/bin/jb and not in the global /bin dir.

Can the makefile be updated to work with just calling jb instead? I have added the go bin path to my user's $PATH as well, but since the /bin/jb location is hardcoded, I have to manually add a symlink or install as root, which is a little strange.

geerlingguy commented 4 years ago

Ah, I think I was a bit confused...

If I run $ go env GOPATH it output /home/myuser/go.

However, the $GOPATH env var was not set, which the Makefile uses. So I had to also export GOPATH=/home/myuser/go so the environment variable was set. (Also note that you can't set GOPATH=~/go because you get the error:

go: GOPATH entry cannot start with shell metacharacter '~'
carlosedp commented 4 years ago

Weird because in the makefile, it's like:

GOPATH ?= `$(pwd)`

JSONNET_BIN := $(GOPATH)/bin/jsonnet
JB_BINARY := $(GOPATH)/bin/jb

It should install in your GOPATH if it's already defined otherwise it would install into current dir (pwd).

carlosedp commented 4 years ago

Yes, it must be an absolute path. I just tested without the GOPATH variable and it really fails. I will change the Makefile to warn the user to have the GOPATH set.

Did it work this way?

geerlingguy commented 4 years ago

That's weird, $GOPATH was definitely empty (confirmed with an echo and env), and go installed the bins in ~/go/bin.

My workaround worked fine, and right now I don't have time to dig in any deeper (already burned about 4 more hours on this task than I planned; this repo has saved me a lot of time ;).

Feel free to close this issue, and hopefully if someone else who fights with GOPATH and env vars like I do so often has the same problem, Google will lead them here :)

carlosedp commented 4 years ago

Nice! Glad it helped. I'll take a look into this to avoid further problems like this :)

carlosedp commented 4 years ago

Fixed by a6a1133ec5cdbe464b31b83ca35f1ed713e0a2fc. Can you check?

geerlingguy commented 4 years ago

@carlosedp Testing now.

geerlingguy commented 4 years ago

It looks like that worked! I dropped all my workarounds and it's picking up the GOPATH correctly.

One weird thing is all the manifests are there, but completely empty after I make vendor && make... not sure what's up with that (I'm running Go 1.11), but if I determine it's something not my fault I may open a separate issue. (This issue occurred prior to this commit though, so this commit didn't introduce a regression there.)

geerlingguy commented 4 years ago

The fix worked for the GOPATH, but I did find another issue and I'll open up a separate issue for it (it's unrelated).