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

x/mobile: Does not work with go.mod `replace` #27324

Open
petethepig opened this Issue Aug 28, 2018 · 4 comments

Comments

Projects
None yet
6 participants
@petethepig

petethepig commented Aug 28, 2018

What version of Go are you using (go version)?

$ go version
go version go1.11 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/username/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/username/.gvm/pkgsets/go1.11/global"
GOPROXY=""
GORACE=""
GOROOT="/Users/username/.gvm/gos/go1.11"
GOTMPDIR=""
GOTOOLDIR="/Users/username/.gvm/gos/go1.11/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/username/go-project/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zg/ssp6j1213dg2nd1l8wmc1xs40000gn/T/go-build851930379=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I created a very basic go project that illustrates the issue: https://github.com/petethepig/gomobilebug

There's a go.mod file, notice the use of replace:

module github.com/petethepig/gomobilebug

require (
	github.com/google/netstack v0.0.0
	golang.org/x/mobile v0.0.0-20180808221059-bceb7ef27cc6 // indirect
)

replace github.com/google/netstack v0.0.0 => github.com/petethepig/netstack v0.0.0-20171026205909-b4b77f7e31f6

I run gomobile bind -v -target ios .

What did you expect to see?

I expected the command to succeed.

What did you see instead?

Instead the command throws an error:

$ gomobile bind -v -target ios .
type-checking package "." failed (/Users/username/Dev/st/example/main.go:6:2: could not import github.com/google/netstack/tcpip (type-checking package "github.com/google/netstack/tcpip" failed (/Users/username/.gvm/pkgsets/go1.11/global/pkg/mod/github.com/petethepig/netstack@v0.0.0-20171026205909-b4b77f7e31f6/tcpip/tcpip.go:25:2: could not import github.com/google/netstack/tcpip/buffer (cannot find package "github.com/google/netstack/tcpip/buffer" in any of:
	/Users/username/.gvm/gos/go1.11/src/github.com/google/netstack/tcpip/buffer (from $GOROOT)
	/Users/username/.gvm/pkgsets/go1.11/global/src/github.com/google/netstack/tcpip/buffer (from $GOPATH)))))

gomobile: /Users/username/.gvm/pkgsets/go1.11/global/bin/gobind -lang=go,objc -outdir=/var/folders/zg/ssp6j1213dg2nd1l8wmc1xs40000gn/T/gomobile-work-114613772 -tags=ios . failed: exit status 1

It seems like something somewhere fails to properly replace the paths (For example, it searches for github.com/google/netstack/tcpip/buffer package in /Users/username/.gvm/gos/go1.11/src/github.com/google/netstack/tcpip/buffer when it should be searching for it somewhere like /Users/username/.gvm/pkgsets/go1.11/global/pkg/mod/github.com/petethepig/netstack@v0.0.0-20171026205909-b4b77f7e31f6/tcpip/buffer.

Unfortunately I am not that familiar with golang codebase so I need help figuring out how to fix this.

@gopherbot gopherbot added this to the Unreleased milestone Aug 28, 2018

@gopherbot gopherbot added the mobile label Aug 28, 2018

@petethepig petethepig changed the title from x/mobile: Does not work with go modules `replace` to x/mobile: Does not work with go.mod `replace` Aug 30, 2018

@FiloSottile

This comment has been minimized.

Member

FiloSottile commented Aug 30, 2018

Looks like a partial duplicate of #27300.

@evenardo

This comment has been minimized.

evenardo commented Oct 10, 2018

'''
env go111module=off gomobile bind
'''
it's will temporarily worked fine

@myitcv

This comment has been minimized.

Member

myitcv commented Nov 14, 2018

cc @eliasnaur - some time has elapsed since this issue and I'm not sufficiently up to speed to know whether mobile is now modules-aware.

@eliasnaur

This comment has been minimized.

Contributor

eliasnaur commented Nov 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment