heroku / heroku-buildpack-go

Heroku Go Buildpack
https://devcenter.heroku.com/categories/go
MIT License
792 stars 511 forks source link

Unclear what the error message is on build failure #372

Closed ahmetb closed 4 years ago

ahmetb commented 4 years ago

I'm using pack build --builder heroku/buildpacks command to build this repository https://github.com/hyperscale/hyperpic at 8e18694.

I'm getting an error that is not very clear: [builder] Error: failed to build: exit status 2.

There are no other errors next to it, just that the previous line before fail actually does a go get on github.com/pkg/errors package. My suspicion is that this is somehow interpreted as error.

image

go mod download works fine locally.

also I must note that there's no procfile or main.go in the root, so maybe something else is failing.

ghost commented 4 years ago

AFAICT the error is pkg-config: exit status 1.

This is likely because the libvips, which is used by github.com/h2non/bimg isn't in the image that pack is using.

ahmetb commented 4 years ago

Hmm I'm not sure.

Here's a clean golang:1-alpine docker image that also doesn't have libvips, and it does go mod download there just fine.

$ docker run --rm -i -t golang:1-alpine
Unable to find image 'golang:1-alpine' locally
1-alpine: Pulling from library/golang
9d48c3bd43c5: Pull complete
7f94eaf8af20: Pull complete
9fe9984849c1: Pull complete
9f41b4213f39: Pull complete
33c1f6efaf8c: Pull complete
Digest: sha256:2293e952c79b8b3a987e1e09d48b6aa403d703cef9a8fa316d30ba2918d37367
Status: Downloaded newer image for golang:1-alpine
/go # git -h
/bin/sh: git: not found
/go # apk add --no-cache git
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
(1/5) Installing nghttp2-libs (1.39.2-r0)
(2/5) Installing libcurl (7.66.0-r0)
(3/5) Installing expat (2.2.8-r0)
(4/5) Installing pcre2 (10.33-r0)
(5/5) Installing git (2.22.0-r0)
Executing busybox-1.30.1-r2.trigger
OK: 21 MiB in 20 packages
/go # git clone https://github.com/hyperscale/hyperpic.git; cd hyperpic
Cloning into 'hyperpic'...
remote: Enumerating objects: 52, done.
remote: Counting objects: 100% (52/52), done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 1125 (delta 28), reused 13 (delta 4), pack-reused 1073
Receiving objects: 100% (1125/1125), 4.22 MiB | 11.90 MiB/s, done.
Resolving deltas: 100% (683/683), done.
/go/hyperpic # GOPROXY=https://proxy.golang.org go mod download
go: finding cloud.google.com/go v0.26.0
go: finding github.com/BurntSushi/toml v0.3.1
go: finding github.com/OneOfOne/xxhash v1.2.2
go: finding github.com/PuerkitoBio/purell v1.1.0
go: finding github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: finding github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
go: finding github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
go: finding github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6
go: finding github.com/asaskevich/govalidator v0.0.0-20180315120708-ccb8e960c48f
go: finding github.com/beorn7/perks v1.0.0
go: finding github.com/cespare/xxhash v1.1.0
go: finding github.com/client9/misspell v0.3.4
go: finding github.com/coreos/bbolt v1.3.2
go: finding github.com/coreos/etcd v3.3.10+incompatible
go: finding github.com/coreos/go-semver v0.2.0
go: finding github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
go: finding github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/dgrijalva/jwt-go v3.2.0+incompatible
go: finding github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954
go: finding github.com/euskadi31/go-server v0.0.0-20191009113222-686c429d32ee
go: finding github.com/euskadi31/go-service v1.3.1
go: finding github.com/fsnotify/fsnotify v1.4.7
go: finding github.com/ghodss/yaml v1.0.0
go: finding github.com/go-kit/kit v0.8.0
go: finding github.com/go-logfmt/logfmt v0.4.0
go: finding github.com/go-openapi/analysis v0.0.0-20180126163718-f59a71f0ece6
go: finding github.com/go-openapi/errors v0.0.0-20180827163446-87bb65328877
go: finding github.com/go-openapi/jsonpointer v0.0.0-20180825180259-52eb3d4b47c6
go: finding github.com/go-openapi/jsonreference v0.0.0-20180825180305-1c6a3fa339f2
go: finding github.com/go-openapi/loads v0.0.0-20171207192234-2a2b323bab96
go: finding github.com/go-openapi/runtime v0.0.0-20180325232944-62281b694b39
go: finding github.com/go-openapi/spec v0.0.0-20180406021525-370d9e047557
go: finding github.com/go-openapi/strfmt v0.0.0-20180407011102-481808443b00
go: finding github.com/go-openapi/swag v0.0.0-20180908172849-dd0dad036e67
go: finding github.com/go-openapi/validate v0.0.0-20180222165948-180bba53b988
go: finding github.com/go-stack/stack v1.8.0
go: finding github.com/go-yaml/yaml v2.1.0+incompatible
go: finding github.com/gogo/protobuf v1.2.1
go: finding github.com/golang/gddo v0.0.0-20181116215533-9bd4a3295021
go: finding github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
go: finding github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef
go: finding github.com/golang/mock v1.1.1
go: finding github.com/golang/protobuf v1.3.1
go: finding github.com/google/btree v1.0.0
go: finding github.com/google/go-cmp v0.2.0
go: finding github.com/google/uuid v1.0.0
go: finding github.com/gorilla/handlers v1.4.2
go: finding github.com/gorilla/mux v1.7.3
go: finding github.com/gorilla/schema v1.1.0
go: finding github.com/gorilla/websocket v1.4.0
go: finding github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
go: finding github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
go: finding github.com/grpc-ecosystem/grpc-gateway v1.9.0
go: finding github.com/h2non/bimg v1.0.19
go: finding github.com/h2non/filetype v1.0.10
go: finding github.com/hashicorp/hcl v1.0.0
go: finding github.com/jonboulle/clockwork v0.1.0
go: finding github.com/json-iterator/go v1.1.6
go: finding github.com/julienschmidt/httprouter v1.2.0
go: finding github.com/justinas/alice v0.0.0-20171023064455-03f45bd4b7da
go: finding github.com/kisielk/errcheck v1.1.0
go: finding github.com/kisielk/gotool v1.0.0
go: finding github.com/konsorten/go-windows-terminal-sequences v1.0.1
go: finding github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
go: finding github.com/kr/pretty v0.1.0
go: finding github.com/kr/pty v1.1.1
go: finding github.com/kr/text v0.1.0
go: finding github.com/magiconair/properties v1.8.0
go: finding github.com/mailru/easyjson v0.0.0-20180323154445-8b799c424f57
go: finding github.com/matttproud/golang_protobuf_extensions v1.0.1
go: finding github.com/mitchellh/mapstructure v1.1.2
go: finding github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: finding github.com/modern-go/reflect2 v1.0.1
go: finding github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223
go: finding github.com/oklog/ulid v1.3.1
go: finding github.com/opentracing/opentracing-go v1.1.0
go: finding github.com/pbnjay/memory v0.0.0-20190104145345-974d429e7ae4
go: finding github.com/pborman/uuid v1.2.0
go: finding github.com/pelletier/go-toml v1.2.0
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding github.com/prometheus/client_golang v0.9.4
go: finding github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90
go: finding github.com/prometheus/common v0.4.1
go: finding github.com/prometheus/procfs v0.0.2
go: finding github.com/prometheus/tsdb v0.7.1
go: finding github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af
go: finding github.com/rs/cors v1.7.0
go: finding github.com/rs/xid v1.2.1
go: finding github.com/rs/zerolog v1.15.0
go: finding github.com/sirupsen/logrus v1.2.0
go: finding github.com/soheilhy/cmux v0.1.4
go: finding github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72
go: finding github.com/spf13/afero v1.1.2
go: finding github.com/spf13/cast v1.3.0
go: finding github.com/spf13/jwalterweatherman v1.0.0
go: finding github.com/spf13/pflag v1.0.3
go: finding github.com/spf13/viper v1.4.0
go: finding github.com/stretchr/objx v0.1.1
go: finding github.com/stretchr/testify v1.4.0
go: finding github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5
go: finding github.com/ugorji/go v1.1.4
go: finding github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2
go: finding github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77
go: finding github.com/zenazn/goji v0.9.0
go: finding go.etcd.io/bbolt v1.3.2
go: finding go.uber.org/atomic v1.4.0
go: finding go.uber.org/multierr v1.1.0
go: finding go.uber.org/zap v1.10.0
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3
go: finding golang.org/x/net v0.0.0-20190522155817-f3200d17e092
go: finding golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
go: finding golang.org/x/sync v0.0.0-20190423024810-112230192c58
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: finding golang.org/x/text v0.3.0
go: finding golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
go: finding golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc
go: finding google.golang.org/appengine v1.1.0
go: finding google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8
go: finding google.golang.org/grpc v1.21.0
go: finding gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: finding gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
go: finding gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528
go: finding gopkg.in/resty.v1 v1.12.0
go: finding gopkg.in/yaml.v2 v2.2.2
go: finding honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099
/go/hyperpic #

There's no libvips in this environment (find / -name 'libvip*')

ghost commented 4 years ago

The buildpack successfully downloads all the modules. The error happens after the final go: extracting .... message which signals that it happened during compilation. This is the time when CGO will be involved as packages are compiled.

ahmetb commented 4 years ago

You're right, I just tried go build ./... and observed the error. Thanks for helping out.

/go/hyperpic # go build -v ./...
github.com/stretchr/objx
gopkg.in/yaml.v2
github.com/stretchr/testify/assert
github.com/stretchr/testify/mock
github.com/euskadi31/go-server/response/encoder
github.com/go-openapi/errors
github.com/mailru/easyjson/jlexer
github.com/mailru/easyjson/buffer
github.com/mailru/easyjson/jw
github.com/go-openapi/jsonpointer
github.com/PuerkitoBio/urlesc
golang.org/x/text/transform
golang.org/x/text/unicode/bidi
golang.org/x/text/secure/bidirule
golang.org/x/text/unicode/norm
golang.org/x/net/idna
golang.org/x/text/width
github.com/PuerkitoBio/purell
github.com/go-openapi/jsonreference
github.com/go-openapi/spec
github.com/asaskevich/govalidator
github.com/mitchellh/mapstructure
gopkg.in/mgo.v2/internal/json
gopkg.in/mgo.v2/bson
github.com/go-openapi/strfmt
github.com/go-openapi/analysis
github.com/go-openapi/loads
golang.org/x/net/context
github.com/go-openapi/runtime
github.com/go-openapi/validate
github.com/golang/gddo/httputil/header
github.com/golang/gddo/httputil
github.com/euskadi31/go-server/response
github.com/gorilla/handlers
github.com/gorilla/mux
github.com/prometheus/client_golang/prometheus/promhttp
github.com/rs/cors
github.com/euskadi31/go-server
github.com/euskadi31/go-service
github.com/rs/xid
github.com/rs/zerolog/hlog
github.com/hyperscale/hyperpic/pkg/hyperpic/logger
github.com/hyperscale/hyperpic/pkg/hyperpic/fsutil
github.com/gorilla/schema
github.com/h2non/bimg
# pkg-config --cflags  -- vips vips vips vips
pkg-config: exec: "pkg-config": executable file not found in $PATH
github.com/h2non/filetype/matchers/isobmff
github.com/h2non/filetype/types
github.com/h2non/filetype/matchers
github.com/h2non/filetype
github.com/hyperscale/hyperpic/pkg/hyperpic/memfs
github.com/hyperscale/hyperpic/pkg/hyperpic/server
github.com/hyperscale/hyperpic/cmd/hyperpic/app/asset
github.com/hyperscale/hyperpic/cmd/hyperpic/app/metrics
github.com/hyperscale/hyperpic/pkg/hyperpic/httputil/header
github.com/justinas/alice
github.com/hyperscale/hyperpic/pkg/hyperpic/version
github.com/pbnjay/memory
golang.org/x/sys/unix
github.com/fsnotify/fsnotify
github.com/hashicorp/hcl/hcl/strconv
github.com/hashicorp/hcl/hcl/token
github.com/hashicorp/hcl/hcl/ast
github.com/hashicorp/hcl/hcl/scanner
github.com/hashicorp/hcl/hcl/parser
github.com/hashicorp/hcl/json/token
github.com/hashicorp/hcl/json/scanner
github.com/hashicorp/hcl/json/parser
github.com/hashicorp/hcl
github.com/hashicorp/hcl/hcl/printer
github.com/magiconair/properties
github.com/pelletier/go-toml
github.com/spf13/afero/mem
github.com/spf13/afero
github.com/spf13/cast
github.com/spf13/jwalterweatherman
github.com/spf13/pflag
github.com/spf13/viper
github.com/pkg/errors

/go/hyperpic # echo $?
2
ghost commented 4 years ago

I've not used pack before now, but you will need to have it install that package before running the go buildpack. If this were on Heroku I would suggest using the apt buildpack.

ahmetb commented 4 years ago

It's not a big deal, but I recommend pack CLI to wrap the error message from exec and explain what happened more clearly, such as:

Error: failed to build: 'go build ./...' failed: exit status: 7