heroku / heroku-buildpack-go

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

Problem installing dependencies from Github #72

Closed jelder closed 9 years ago

jelder commented 9 years ago

Followed the guide, getting cannot find package for all of my Github-hosted dependencies. Pretty new to Go, so not sure if this is my fault or an actual bug.

Counting objects: 30, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (26/26), done.
Writing objects: 100% (30/30), 5.24 KiB | 0 bytes/s, done.
Total 30 (delta 9), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Fetching custom git buildpack... done
remote: -----> Go app detected
remote: -----> Installing go1.2... done
remote: -----> Running: godep go install -tags heroku ./...
remote: beacon.go:7:2: cannot find package "github.com/dchest/uniuri" in any of:
remote:     /app/tmp/cache/go1.2/go/src/pkg/github.com/dchest/uniuri (from $GOROOT)
remote:     /tmp/build_0a32b34caa3cfe94f2dd00603ef45127/.heroku/g/src/github.com/jelder/beacon/Godeps/_workspace/src/github.com/dchest/uniuri (from $GOPATH)
remote:     /tmp/build_0a32b34caa3cfe94f2dd00603ef45127/.heroku/g/src/github.com/dchest/uniuri
remote: beacon.go:8:2: cannot find package "github.com/garyburd/redigo/redis" in any of:
remote:     /app/tmp/cache/go1.2/go/src/pkg/github.com/garyburd/redigo/redis (from $GOROOT)
remote:     /tmp/build_0a32b34caa3cfe94f2dd00603ef45127/.heroku/g/src/github.com/jelder/beacon/Godeps/_workspace/src/github.com/garyburd/redigo/redis (from $GOPATH)
remote:     /tmp/build_0a32b34caa3cfe94f2dd00603ef45127/.heroku/g/src/github.com/garyburd/redigo/redis
remote: godep: go exit status 1
remote:
remote:  !     Push rejected, failed to compile Go app
remote:
remote: Verifying deploy...
remote:
remote: !   Push rejected to beacon.
remote:
To https://git.heroku.com/beacon.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/beacon.git'

My Godeps/Godeps.json:


{
    "ImportPath": "github.com/jelder/beacon",
    "GoVersion": "go1.2",
    "Deps": [
        {
            "ImportPath": "github.com/dchest/uniuri",
            "Rev": "dc985c3409977cc7670dc2043f31d60bea764a51"
        },
        {
            "ImportPath": "github.com/garyburd/redigo/internal",
            "Rev": "61e2910408efd40dafb3c7d856a4cf8aeb5fb1c6"
        },
        {
            "ImportPath": "github.com/garyburd/redigo/redis",
            "Rev": "61e2910408efd40dafb3c7d856a4cf8aeb5fb1c6"
        }
    ]
}

App repo: https://github.com/jelder/beacon/

catsby commented 9 years ago

Hello –

From the guide:

$ godep save 

This will save a list of dependencies to the file Godeps/Godeps.json and copy their source code into Godeps/_workspace.

Looking at the repo you shared, I don't see the source code copied into Godeps/_workspace:

That's why they build is failing, because it can't find the source there. It should have the source of your projects copied (see here in heroku/busl as an example).

Can you try godep save again, maybe after making sure you're installed Godep is up to date? (go get -u github.com/tools/godep)

jelder commented 9 years ago

@catsby Thanks for looking. I installed Go for the first time today, but ran go get -u github.com/tools/godep anyway just to be safe.

godep save leaves my repo clean. Locally, Godeps/_workspace has the source for all my dependencies. I must have had a .gitignore entry somewhere preventing src/ from getting added, but add -Af fixed it.

catsby commented 9 years ago

Awesome, glad you got things sorted. Happy hacking :rocket:

parkan commented 9 years ago

Does this mean Godeps/_workspace has to be checked into the repo to use this buildpack? Is this a go idiosyncrasy? I have never checked in the actual dependencies into VCS in other languages, and other buildpacks will pull down your gems/jars/etc down at build time.

Am I misunderstanding something?

freeformz commented 9 years ago

Yes, vendoring your dependencies by copying them into your code using a tool or by hand is the Go way.