Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-compilation fails without explicitly installing mousetrap #250

Closed
diwakergupta opened this issue Mar 11, 2016 · 5 comments

Comments

@diwakergupta
Copy link

@diwakergupta diwakergupta commented Mar 11, 2016

I have a CLI built using cobra: dropbox/dbxcli. If I try to cross-compile it (using gox, but other methods fail similarly), I get failures like:

21.32s$ gox -osarch="darwin/amd64 linux/amd64 windows/amd64" -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}"
Number of parallel builds: 1
-->     linux/amd64: github.com/dropbox/dbxcli
-->   windows/amd64: github.com/dropbox/dbxcli
-->    darwin/amd64: github.com/dropbox/dbxcli
1 errors occurred:
--> windows/amd64 error: exit status 1
Stderr: ../../spf13/cobra/command_win.go:9:2: cannot find package "github.com/inconshreveable/mousetrap" in any of:
    /home/travis/.gimme/versions/go1.6.linux.amd64/src/github.com/inconshreveable/mousetrap (from $GOROOT)
    /home/travis/gopath/src/github.com/inconshreveable/mousetrap (from $GOPATH)

You can see more details here: https://travis-ci.org/dropbox/dbxcli/builds/115377102

Explicitly installing mousetrap does fix the issue, but filing this because it violates principle of least surprise.

@lordnynex

This comment has been minimized.

Copy link

@lordnynex lordnynex commented Mar 31, 2016

FWIW, I can not reproduce this.

@spf13

This comment has been minimized.

Copy link
Owner

@spf13 spf13 commented Apr 27, 2016

@diwakergupta mousetrap is a required dependency for Windows builds. Cross compilation, or even just compiling on Windows will fail if this library isn't present.

In your build osx and linux built fine. If your command was
gox -osarch="darwin/amd64 linux/amd64" -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}"
It would also run correctly.

Perhaps I'm missing something, but I everything I see here is working as expected.
Closing, but feel free to re-open with additional information.

@spf13 spf13 closed this Apr 27, 2016
@patrick-motard

This comment has been minimized.

Copy link

@patrick-motard patrick-motard commented Apr 11, 2018

@spf13 I'm confused by your response. You're saying that mousetrap is a required depenency for windows builds. Okay I get that.

Then you say linux and osx build fine if you just build those. Yes, I agree with that, what does that have to do with the windows compile issue?

Are you saying that I personally need to include mouse trap as a dependency of my project if I want to both use cobra as a depency and compile against windows? If so, how do I do that? When and where in my project do i reference that dependency? Wouldn't it throw an error since it's not explicitly used?

The only solution i see is to clone mousetrap to $GOPATH prior to building against windows. Why would we manually install dependencies? If cobra requires this library, why doesn't it install when I run go get -d -v ./...? Is it because go get assumes it needs to get linux depenencies only because i'm issuing go get from a linux machine? Is there a way for go get to install all dependencies for all architectures?

@eparis

This comment has been minimized.

Copy link
Collaborator

@eparis eparis commented Apr 11, 2018

What you wanted to do was GOOS=windows go get -u github.com/spf13/cobra That will get the windows dependencies, rather than the local OS dependencies.

@piot

This comment has been minimized.

Copy link

@piot piot commented Apr 5, 2019

I have the same problem. What is the exact solution with gox?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.