ncabatoff / script-exporter

Prometheus exporter to invoke scripts and parse their output as metrics.
MIT License
37 stars 20 forks source link

Compile problem #2

Closed hacker-cb closed 7 years ago

hacker-cb commented 7 years ago

It is impossible to compile project now. Seems that dependencies was moved

$ go build
metrics.go:4:2: cannot find package "bosun.org/opentsdb" in any of:
    /usr/lib/go/src/pkg/bosun.org/opentsdb (from $GOROOT)
    ($GOPATH not set)
command.go:5:2: cannot find package "context" in any of:
    /usr/lib/go/src/pkg/context (from $GOROOT)
    ($GOPATH not set)
metrics.go:7:2: cannot find package "github.com/prometheus/client_golang/prometheus" in any of:
    /usr/lib/go/src/pkg/github.com/prometheus/client_golang/prometheus (from $GOROOT)
    ($GOPATH not set)
metrics.go:8:2: cannot find package "github.com/prometheus/client_golang/prometheus/promhttp" in any of:
    /usr/lib/go/src/pkg/github.com/prometheus/client_golang/prometheus/promhttp (from $GOROOT)
    ($GOPATH not set)
metrics.go:9:2: cannot find package "github.com/prometheus/client_model/go" in any of:
    /usr/lib/go/src/pkg/github.com/prometheus/client_model/go (from $GOROOT)
    ($GOPATH not set)
metrics.go:10:2: cannot find package "github.com/prometheus/common/expfmt" in any of:
    /usr/lib/go/src/pkg/github.com/prometheus/common/expfmt (from $GOROOT)
ncabatoff commented 7 years ago

All the dependencies should be vendored since changeset 813d263ec74d3df5e6ecdc317016269fb7a30512 back in May. What go version are you using? If 1.5, make sure GO15VENDOREXPERIMENT=1. If older than 1.5, time to upgrade.

hacker-cb commented 7 years ago

I have upgraded and all works fine now. Thank you.

ncabatoff commented 7 years ago

Great, glad I could help.

microwl43 commented 5 years ago

I am seeing the same as @Hacker-CB. Documentation for 1.12.4 says "This release removes support for the GO15VENDOREXPERIMENT environment variable". Any ideas? $ go version go1.12.4 linux/amd64

$ go build metrics.go:4:2: cannot find package "bosun.org/opentsdb" in any of: /usr/local/go/src/bosun.org/opentsdb (from $GOROOT) /root/go/src/bosun.org/opentsdb (from $GOPATH) main.go:17:2: cannot find package "github.com/prometheus/client_golang/prometheus" in any of: /usr/local/go/src/github.com/prometheus/client_golang/prometheus (from $GOROOT) /root/go/src/github.com/prometheus/client_golang/prometheus (from $GOPATH) main.go:18:2: cannot find package "github.com/prometheus/client_golang/prometheus/promhttp" in any of: /usr/local/go/src/github.com/prometheus/client_golang/prometheus/promhttp (from $GOROOT) /root/go/src/github.com/prometheus/client_golang/prometheus/promhttp (from $GOPATH) metrics.go:9:2: cannot find package "github.com/prometheus/client_model/go" in any of: /usr/local/go/src/github.com/prometheus/client_model/go (from $GOROOT) /root/go/src/github.com/prometheus/client_model/go (from $GOPATH) metrics.go:10:2: cannot find package "github.com/prometheus/common/expfmt" in any of: /usr/local/go/src/github.com/prometheus/common/expfmt (from $GOROOT) /root/go/src/github.com/prometheus/common/expfmt (from $GOPATH)

ncabatoff commented 5 years ago

GO15VENDOREXPERIMENT is no longer needed, as of Go 1.6 it was the default behaviour and as of Go 1.7 it was removed as an option altogether.

It looks like you haven't set the env var GOPATH, which means Go is using the default of $HOME/go. Projects that don't use the newfangled Go Modules feature (which is true of script-exporter) need to be checked out under $GOPATH/src/pkgpath to work properly. In your case, it looks like you're running as root, so you should clone the repo to /root/go/src/github.com/ncabatoff/script-exporter.

You're probably aware already, but do note that I make binary releases available for most platforms (on the releases tab of the project), and also docker.