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

go 1.7beta1: go vet: import failed: fmt.a:1:4 (byte offset = 3): expected keyword package, got "cn" #16044

Closed
aaronbee opened this issue Jun 12, 2016 · 14 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@aaronbee
Copy link

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go1.7beta1
  2. What operating system and processor architecture are you using (go env)?
    darwin amd64
  3. What did you do?
    Installed go1.7beta1 with brew upgrade go --devel. Executed go vet on any go file.
  4. What did you expect to see?
    Normal vet output
  5. What did you see instead?
    This is repeated twice per file:
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"

And then it would print out normal vet warnings if there were any for the file:

foo/bar.go:184: arg baz for printf verb %s of wrong type: foo.Bar
@tsuna
Copy link
Contributor

tsuna commented Jun 12, 2016

I'm seeing the same problem.

@ianlancetaylor
Copy link
Contributor

What is the output of go vet -x?

Do you have GOROOT set in the environment?

@ianlancetaylor ianlancetaylor added this to the Go1.7 milestone Jun 12, 2016
@aaronbee
Copy link
Author

$ 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"

@griesemer
Copy link
Contributor

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.

@griesemer griesemer added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jun 13, 2016
@aaronbee
Copy link
Author

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

@robpike
Copy link
Contributor

robpike commented Jun 13, 2016

Version skew. I've seen this myself but the solution is just to update the installation.

@robpike robpike closed this as completed Jun 13, 2016
@adg
Copy link
Contributor

adg commented Jun 14, 2016

@griesemer what do you think about making the gcimporter detect old versions of the object files, and reporting a more useful error message?

@griesemer
Copy link
Contributor

@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).

@adg
Copy link
Contributor

adg commented Jun 14, 2016

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
#16044 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AIDilUooqdjVpoeF22Tyh4w_MaELk09Eks5qLjMigaJpZM4Iz3Hc
.

@kevinburke
Copy link
Contributor

kevinburke commented Jun 15, 2016

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.

@kevinburke
Copy link
Contributor

kevinburke commented Jun 15, 2016

Oh, I'm an idiot. It's importing types from a Godeps directory, not from the standard library. My apologies.

@mmatczuk
Copy link

mmatczuk commented Feb 16, 2017

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.

@griesemer
Copy link
Contributor

@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.

@mmatczuk
Copy link

@griesemer thanks I think it's not related to mixing versions, anyway I'll double check that.

@golang golang locked and limited conversation to collaborators Feb 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

9 participants