Closed aaronbee closed 8 years ago
I'm seeing the same problem.
What is the output of go vet -x
?
Do you have GOROOT
set in the environment?
$ go vet -x
/usr/local/Cellar/go/1.7beta1/libexec/pkg/tool/darwin_amd64/vet sample.go
vet: import failed: reading export data: /usr/local/Cellar/go/1.7beta1/libexec/pkg/darwin_amd64/fmt.a: import error /usr/local/Cellar/go/1.7beta1/libexec/pkg/darwin_amd64/fmt.a:1:4 (byte offset = 3): expected keyword package, got "cn"
vet: import failed: reading export data: /usr/local/Cellar/go/1.7beta1/libexec/pkg/darwin_amd64/fmt.a: import error /usr/local/Cellar/go/1.7beta1/libexec/pkg/darwin_amd64/fmt.a:1:4 (byte offset = 3): expected keyword package, got "cn"
exit status 1
GOROOT
is not set in the environment.
Here is the output of go env
:
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/aaronb/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7beta1/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7beta1/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dh/8tf0gx091zs_02mw_s0c956w0000gp/T/go-build166305989=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
From the error message, it looks like go vet is using an old gcimporter that doesn't know about the new binary export format (the export data of which happens to start in this case with "cn" rather than "package").
@aaronbee Can you please verify that you are running the latest version of go vet? Specifically, a version compiled with the 1.7 compiler and using 1.7 libraries? For instance, in the std library dir, you should have a file src/go/internal/gcimporter/bimport.go
that is up-to-date.
If this is all true, try building the std library (make.bash in the src directory) and confirm/deny that the error is still present. Thanks.
Yeah, that fixed it.
Here are the steps I took:
export GOROOT_BOOTSTRAP=/usr/local/Cellar/go/1.6.2/libexec # go1.6.2 installation from brew
cd /usr/local/Cellar/go/1.7beta1/libexec/src
./make.bash
This would indicate there is likely a bug in the brew install script for go. https://github.com/Homebrew/homebrew-core/blob/master/Formula/go.rb
Version skew. I've seen this myself but the solution is just to update the installation.
@griesemer what do you think about making the gcimporter detect old versions of the object files, and reporting a more useful error message?
@adg It does detect old versions and automatically uses the old format if present - no need for an error message. What happened here is the opposite: the installed version of gcimporter didn't know about the new version because it was out of date. There's not much I can do about that automatically (w/o knowing the future, at least).
Oh, sorry, I misunderstood the error report.
On 14 June 2016 at 14:50, Robert Griesemer notifications@github.com wrote:
@adg https://github.com/adg It does detect old versions and automatically uses the old format if present - no need for an error message. What happened here is the opposite: the installed version of gcimporter didn't know about the new version because it was out of date. There's not much I can do about that automatically (w/o knowing the future, at least).
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/golang/go/issues/16044#issuecomment-225779280, or mute the thread https://github.com/notifications/unsubscribe/AIDilUooqdjVpoeF22Tyh4w_MaELk09Eks5qLjMigaJpZM4Iz3Hc .
Apologies but I'm still hitting this error message. It might not be a problem in the Go stdlib, but I'd appreciate your feedback.
I installed this package:
go get github.com/gophergala2016/gophernotes
cd $GOPATH/src/github.com/gophergala2016/gophernotes
go install ./...
On Mac you need zeromq 2.2 to install that. You'll also want to install the following additional packages
go get github.com/k0kubun/pp
go get github.com/davecgh/go-spew/spew
I then try running
$GOPATH/bin/gophernotes --debug foo.json
where foo.json
is:
{
"shell_port": 51940,
"iopub_port": 51941,
"stdin_port": 51942,
"control_port": 51943,
"hb_port": 51944,
"ip": "127.0.0.1",
"key": "80336d88-cab1-4685-bc56-8c8cc90e8061",
"transport": "tcp",
"signature_scheme": "hmac-sha256",
"kernel_name": "gophernotes"
}
This fails with the following error message:
$ ~/code/go/bin/gophernotes --debug /Users/kevin/Library/Jupyter/runtime/kernel-992089f4-c552-4860-b7a3-c2135ef5bb5f.json
repl.go:118 could not import "github.com/k0kubun/pp": reading export data: /Users/kevin/code/go/pkg/darwin_amd64/github.com/k0kubun/pp.a: import error /Users/kevin/code/go/pkg/darwin_amd64/github.com/k0kubun/pp.a:1:4 (byte offset = 3): expected keyword package, got "cn"
repl.go:118 could not import "github.com/davecgh/go-spew/spew": reading export data: /Users/kevin/code/go/pkg/darwin_amd64/github.com/davecgh/go-spew/spew.a: import error /Users/kevin/code/go/pkg/darwin_amd64/github.com/davecgh/go-spew/spew.a:1:4 (byte offset = 3): expected keyword package, got "cn"
repl.go:118 could not import "fmt": reading export data: /Users/kevin/go/pkg/darwin_amd64/fmt.a: import error /Users/kevin/go/pkg/darwin_amd64/fmt.a:1:4 (byte offset = 3): expected keyword package, got "cn"
panic: Could not load pretty printing package (even "fmt"; something is wrong)
goroutine 1 [running]:
panic(0x424db20, 0xc420015730)
/Users/kevin/go/src/runtime/panic.go:500 +0x1a1
main.SetupExecutionEnvironment()
/Users/kevin/code/go/src/github.com/gophergala2016/gophernotes/execution.go:22 +0xef
main.RunKernel(0x7fff5fbff75d, 0x55, 0x4418940, 0xc42002a018)
/Users/kevin/code/go/src/github.com/gophergala2016/gophernotes/gophernotes.go:120 +0x100
main.main()
/Users/kevin/code/go/src/github.com/gophergala2016/gophernotes/main.go:25 +0xc6
Here's the relevant code in repl.go
- it uses types.DefaultImport
:
var initialSource string
for _, pp := range printerPkgs {
_, err := types.DefaultImport(s.Types.Packages, pp.path)
if err == nil {
initialSource = fmt.Sprintf(initialSourceTemplate, pp.path, pp.code)
break
}
debugf("could not import %q: %s", pp.path, err)
}
if initialSource == "" {
return nil, fmt.Errorf(`Could not load pretty printing package (even "fmt"; something is wrong)`)
}
Here's my go env
:
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/kevin/code/go:/usr/local/go"
GORACE=""
GOROOT="/Users/kevin/go"
GOTOOLDIR="/Users/kevin/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dx/x6gx95t14n7bb3v878968fkm0000gn/T/go-build714916141=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
Here's my go version
:
$ go version
go version devel +c4692da Wed Jun 15 00:30:46 2016 +0000 darwin/amd64
I rebuilt using ./make.bash
on tip before running all of the above commands.
Oh, I'm an idiot. It's importing types
from a Godeps directory, not from the standard library. My apologies.
I'm getting the same error on 1.7.5 if I run go clean -i -r ./...
on my project, then go vet breaks, packages from go root get somehow cleaned too, at least for go vet.
@mmatczuk You have packages installed generated by different versions of the compiler. This error will go away if all your installed packages are compiled by the same compiler version.
If it doesn't please file a new issue with exact details how to reproduce the failure. Thanks.
@griesemer thanks I think it's not related to mixing versions, anyway I'll double check that.
Please answer these questions before submitting your issue. Thanks!
go version
)? go1.7beta1go env
)? darwin amd64brew upgrade go --devel
. Executedgo vet
on any go file.And then it would print out normal vet warnings if there were any for the file: