constabulary / gb

gb, the project based build tool for Go
https://getgb.io/
MIT License
2.15k stars 150 forks source link

Using "promu" with gb projects? #699

Closed amitsaha closed 7 years ago

amitsaha commented 7 years ago

Hello, fairly new Golang programmer and have been using gb for a project of mine. I am trying to use promu for building release binaries for my project. However, by default it assumes the project to be in $GOPATH which my project is not (since I am using gb and this is one of the reasons I am using it).

Hence promu build basically fails to find my project. Has anyone tried using it with gb projects?

davecheney commented 7 years ago

I've not used promu, but maybe something like this will coax it into working

env GOPATH=$(gb env GB_SRC_PATH) promu ...

On Fri, Mar 17, 2017 at 4:55 PM, Amit Saha notifications@github.com wrote:

Hello, fairly new Golang programmer and have been using gb for a project https://github.com/amitsaha/gitbackup of mine. I am trying to use promu https://github.com/prometheus/promu for building release binaries for my project. However, by default it assumes the project to be in $GOPATH which my project is not (since I am using gb and this is one of the reasons I am using it).

Hence promu build basically fails to find my project. Has anyone tried using it with gb projects?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/constabulary/gb/issues/699, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcA4_PHYqbe-DihNdSAzWpPQWz_Krsks5rmiBqgaJpZM4MgNRW .

amitsaha commented 7 years ago

Thanks, just to see if I can build without using gb, I tried:

$ env GOPATH=$(gb env GB_SRC_PATH) go build src/gitbackup/main.go src/gitbackup/client.go src/gitbackup/backup.go src/gitbackup/repositories.go

But, it doesn't find the packages in vendor it seems.

davecheney commented 7 years ago

This looks like a different question. There is no mention of the tool you asked about.

On Fri, 17 Mar 2017, 17:25 Amit Saha notifications@github.com wrote:

Thanks, just to see if I can build without using gb, I tried:

$ env GOPATH=$(gb env GB_SRC_PATH) go build src/gitbackup/main.go src/gitbackup/client.go src/gitbackup/backup.go src/gitbackup/repositories.go

But, it doesn't find the packages in vendor it seems.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/constabulary/gb/issues/699#issuecomment-287277264, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcAwSfiw5cAClffu3YgYfHLM8V28Qtks5rmidVgaJpZM4MgNRW .

amitsaha commented 7 years ago

promu is using go build. So I thought it would make it easier for me to first try building directly.

davecheney commented 7 years ago

Can you please show what you tried and everything that you saw.

On Fri, 17 Mar 2017, 17:40 Amit Saha notifications@github.com wrote:

promu is using go build. So I thought it would make it easier for me to first try building directly.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/constabulary/gb/issues/699#issuecomment-287279076, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcA_qZP576fQyn8LhBHUzO0qhYwJbPks5rmirQgaJpZM4MgNRW .

amitsaha commented 7 years ago

Sure.

env GOPATH=$(gb env GB_SRC_PATH) go build src/gitbackup/main.go src/gitbackup/client.go src/gitbackup/backup.go src/gitbackup/repositories.go
src/gitbackup/client.go:4:2: cannot find package "github.com/google/go-github/github" in any of:
    /usr/local/Cellar/go/1.8/libexec/src/github.com/google/go-github/github (from $GOROOT)
    /Users/asaha/work/github.com/amitsaha/gitbackup/src/src/github.com/google/go-github/github (from $GOPATH)
    /Users/asaha/work/github.com/amitsaha/gitbackup/vendor/src/src/github.com/google/go-github/github
src/gitbackup/backup.go:4:2: cannot find package "github.com/mitchellh/go-homedir" in any of:
    /usr/local/Cellar/go/1.8/libexec/src/github.com/mitchellh/go-homedir (from $GOROOT)
    /Users/asaha/work/github.com/amitsaha/gitbackup/src/src/github.com/mitchellh/go-homedir (from $GOPATH)
    /Users/asaha/work/github.com/amitsaha/gitbackup/vendor/src/src/github.com/mitchellh/go-homedir
src/gitbackup/backup.go:5:2: cannot find package "github.com/spf13/afero" in any of:
    /usr/local/Cellar/go/1.8/libexec/src/github.com/spf13/afero (from $GOROOT)
    /Users/asaha/work/github.com/amitsaha/gitbackup/src/src/github.com/spf13/afero (from $GOPATH)
    /Users/asaha/work/github.com/amitsaha/gitbackup/vendor/src/src/github.com/spf13/afero
src/gitbackup/client.go:5:2: cannot find package "github.com/xanzy/go-gitlab" in any of:
    /usr/local/Cellar/go/1.8/libexec/src/github.com/xanzy/go-gitlab (from $GOROOT)
    /Users/asaha/work/github.com/amitsaha/gitbackup/src/src/github.com/xanzy/go-gitlab (from $GOPATH)
    /Users/asaha/work/github.com/amitsaha/gitbackup/vendor/src/src/github.com/xanzy/go-gitlab
src/gitbackup/client.go:6:2: cannot find package "golang.org/x/oauth2" in any of:
    /usr/local/Cellar/go/1.8/libexec/src/golang.org/x/oauth2 (from $GOROOT)
    /Users/asaha/work/github.com/amitsaha/gitbackup/src/src/golang.org/x/oauth2 (from $GOPATH)
    /Users/asaha/work/github.com/amitsaha/gitbackup/vendor/src/src/golang.org/x/oauth2

So I guess, the problem is it's looking for src under the vendor/src directory. So, this works:

$ env GOPATH=/Users/asaha/work/github.com/amitsaha/gitbackup/src:/Users/asaha/work/github.com/amitsaha/gitbackup/vendor/  go build src/gitbackup/main.go src/gitbackup/client.go src/gitbackup/backup.go src/gitbackup/repositories.go

And that allowed me to use promu build as well. Closing this issue. Thanks.

davecheney commented 7 years ago

Hmm, I might have quoted you the wrong go env var, there is one that is specifically taylored for this

On 17 Mar 2017, at 19:22, Amit Saha notifications@github.com wrote:

Closed #699.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

amitsaha commented 7 years ago

Thanks, will be good to know if there was one I could use directly.

davecheney commented 7 years ago

Just run gb env and you'll see all the values

On 17 Mar 2017, at 23:08, Amit Saha notifications@github.com wrote:

Thanks, will be good to know if there was one I could use directly.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.