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

x/mobile/cmd/gomobile: gomobile version shows error #34676

Open
mandelmonkey opened this issue Oct 3, 2019 · 11 comments
Open

x/mobile/cmd/gomobile: gomobile version shows error #34676

mandelmonkey opened this issue Oct 3, 2019 · 11 comments

Comments

@mandelmonkey
Copy link

@mandelmonkey mandelmonkey commented Oct 3, 2019

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

go1.13 darwin/amd64

$ go version

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/chris/Library/Caches/go-build"
GOENV="/Users/chris/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/chris/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/chris/go/src/github.com/lightningnetwork/lnd/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/rp/f7xqr7490tb5_98n7cjvxsx80000gn/T/go-build815709937=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

ran gomobile version after go get golang.org/x/mobile/cmd/gomobile go init

What did you expect to see?

the version number

What did you see instead?

gomobile version gomobile version unknown: mobile repo git log failed: exit status 128, fatal: not a git repository (or any of the parent directories): .git

@hyangah

This comment has been minimized.

Copy link
Contributor

@hyangah hyangah commented Oct 3, 2019

This seems to be another part of gomobile that does not work with the workflow assumed in the module mode. For version, it assumes there is a git repository checked out under GOPATH, which is no longer true in the module mode.

@mandelmonkey What will happen if it is built with GOPATH mode?

GO111MODULE=off go get golang.org/x/mobile/cmd/gomobile
@andybons andybons added this to the Unplanned milestone Oct 3, 2019
@andybons andybons changed the title gomobile version shows error x/mobile/cmd/gomobile: gomobile version shows error Oct 3, 2019
@mandelmonkey

This comment has been minimized.

Copy link
Author

@mandelmonkey mandelmonkey commented Oct 3, 2019

@hyangah I get package golang.org/x/mobile/cmd/gomobile: cannot find package "golang.org/x/mobile/cmd/gomobile" in any of: /usr/local/go/src/golang.org/x/mobile/cmd/gomobile (from $GOROOT) /Users/chris/go/src/golang.org/x/mobile/cmd/gomobile (from $GOPATH)

@hyangah

This comment has been minimized.

Copy link
Contributor

@hyangah hyangah commented Oct 3, 2019

I cannot reproduce it.
@mandelmonkey Have you checked if go get fetched the source file in your $GOPATH/src/.. directory? Or is your $GOPATH not writable?

$ GOPATH=`mktemp -d` GO111MODULE=off go get -x -v golang.org/x/mobile/cmd/gomobile
# get https://golang.org/x/mobile/cmd/gomobile?go-get=1
# get //golang.org/x/mobile/cmd/gomobile?go-get=1: 200 OK (0.158s)
get "golang.org/x/mobile/cmd/gomobile": found meta tag get.metaImport{Prefix:"golang.org/x/mobile", VCS:"git", RepoRoot:"https://go.googlesource.com/mobile"} at //golang.org/x/mobile/cmd/gomobile?go-get=1
get "golang.org/x/mobile/cmd/gomobile": verifying non-authoritative meta tag
# get https://golang.org/x/mobile?go-get=1
# get //golang.org/x/mobile?go-get=1: 200 OK (0.034s)
golang.org/x/mobile (download)
cd .
git clone -- https://go.googlesource.com/mobile /tmp/tmp.SuniQO4FKr/src/golang.org/x/mobile
cd /tmp/tmp.SuniQO4FKr/src/golang.org/x/mobile
git submodule update --init --recursive
cd /tmp/tmp.SuniQO4FKr/src/golang.org/x/mobile
git show-ref
cd /tmp/tmp.SuniQO4FKr/src/golang.org/x/mobile
git submodule update --init --recursive
WORK=/tmp/go-build927349826
golang.org/x/mobile/internal/binres
mkdir -p $WORK/b097/
cat >$WORK/b097/importcfg << 'EOF' # internal
...
mv $WORK/b001/exe/a.out /tmp/tmp.SuniQO4FKr/bin/gomobile
rm -r $WORK/b001/
@mandelmonkey

This comment has been minimized.

Copy link
Author

@mandelmonkey mandelmonkey commented Oct 3, 2019

@hyangah so the error says cannot find package "golang.org/x/mobile/cmd/gomobile" in any of: /usr/local/go/src/golang.org/x/mobile/cmd/gomobile

but I dont have go installed in the /usr/local/ directory is is in the go is installed in /Users/chris/

I need to install go globally?

@hyangah

This comment has been minimized.

Copy link
Contributor

@hyangah hyangah commented Oct 3, 2019

@mandelmonkey No. /usr/local/go/ is your GOROOT which you don't ever want to have gomobile source code at all. The second one (/Users/chris/go/...) is from your default GOPATH. Please check whether go get successfully cloned the git repo under /Users/chris/go/src/golang.org/x/mobile/. go get -x -v will show the details.

@mandelmonkey

This comment has been minimized.

Copy link
Author

@mandelmonkey mandelmonkey commented Oct 3, 2019

@hyangah
here are the results

chris$ GO111MODULE=off go get  -x -v golang.org/x/mobile/cmd/gomobile
package  -x:  -x: invalid import path: malformed import path "\u00a0-x": invalid char '\u00a0'
package -v: -v: invalid import path: malformed import path "-v": leading dash
package golang.org/x/mobile/cmd/gomobile: cannot find package "golang.org/x/mobile/cmd/gomobile" in any of:
	/usr/local/go/src/golang.org/x/mobile/cmd/gomobile (from $GOROOT)
	/Users/chris/go/src/golang.org/x/mobile/cmd/gomobile (from $GOPATH)

and here is the directory under /Users/chris/go/src/golang.org/x/mobile/.

 Christians-MacBook-Pro:go chris$ ls /Users/chris/go/src/golang.org/x/mobile/.
AUTHORS		LICENSE		app		cmd		event		geom		go.sum
CONTRIBUTING.md	PATENTS		asset		codereview.cfg	example		gl		internal
CONTRIBUTORS	README.md	bind		doc		exp		go.mod		testdata
 


@hyangah

This comment has been minimized.

Copy link
Contributor

@hyangah hyangah commented Oct 3, 2019

Some strange shell issue? -x and -v are valid flags and it seems that it's not recognized.

@mandelmonkey

This comment has been minimized.

Copy link
Author

@mandelmonkey mandelmonkey commented Oct 3, 2019

hmm not sure, something changed I get Christians-MacBook-Pro:go chris$ gomobile version gomobile version unknown: binary is out of date, re-install it now a few other coworkers have the same issue, is it a MACOS thing?

@hyangah

This comment has been minimized.

Copy link
Contributor

@hyangah hyangah commented Oct 3, 2019

Again try
GO111MODULE=off gomobile version

Or go to an empty directory and run gomobile version.
From your go env output, I guess the go command is operating in module mode due to the presence of a go.mod file.

This time, try to avoid copy and paste. Seems like the copy-and-paste inserted extra characters like non-breaking space characters.

@mandelmonkey

This comment has been minimized.

Copy link
Author

@mandelmonkey mandelmonkey commented Oct 3, 2019

no prob, I tried again Again try GO111MODULE=off gomobile version

And got

Christians-MacBook-Pro:~ chris$ GO111MODULE=off gomobile version
gomobile version unknown: cannot test gomobile binary: exit status 1, can't load package: package golang.org/x/mobile/cmd/gomobile: cannot find package "golang.org/x/mobile/cmd/gomobile" in any of:
	/usr/local/go/src/golang.org/x/mobile/cmd/gomobile (from $GOROOT)
	/Users/chris/go/src/golang.org/x/mobile/cmd/gomobile (from $GOPATH)

moved to an empty directory and ran these

Christians-MacBook-Pro:empty chris$ GO111MODULE=off gomobile version
gomobile version unknown: cannot test gomobile binary: exit status 1, can't load package: package golang.org/x/mobile/cmd/gomobile: cannot find package "golang.org/x/mobile/cmd/gomobile" in any of:
	/usr/local/go/src/golang.org/x/mobile/cmd/gomobile (from $GOROOT)
	/Users/chris/go/src/golang.org/x/mobile/cmd/gomobile (from $GOPATH)

Christians-MacBook-Pro:empty chris$ gomobile version
gomobile version unknown: cannot test gomobile binary: exit status 1, can't load package: package golang.org/x/mobile/cmd/gomobile: cannot find package "golang.org/x/mobile/cmd/gomobile" in any of:
	/usr/local/go/src/golang.org/x/mobile/cmd/gomobile (from $GOROOT)
	/Users/chris/go/src/golang.org/x/mobile/cmd/gomobile (from $GOPATH)

Christians-MacBook-Pro:empty chris$ export GO111MODULE=on
Christians-MacBook-Pro:empty chris$ gomobile version
gomobile version unknown: binary is out of date, re-install it
Christians-MacBook-Pro:empty chris$ 
@daluu

This comment has been minimized.

Copy link

@daluu daluu commented Mar 24, 2020

Maybe try go get golang.org/x/mobile/cmd/gomobile again from outside any directory that has go.mod. Then run gomobile version from any path. It could be you have to rebuild the binary because it wasn't installed correctly the first time (e.g. fetched from a directory that has go.mod in it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.