gophernotes: Cannot import third party packages

I have done ‘go get -u gonum.org/v1/gonum/…’ and go test without failure. But when I try to do ’ import “gonum.org/v1/gonum/mat” ’ in gophernotes, I got: repl.go:1:8: error loading package "gonum.org/v1/gonum/mat" metadata, maybe you need to download (go get), compile (go build) and install (go install) it? can't find import: "gonum.org/v1/gonum/mat" and this didn’t happen to standard library, only third party library failed

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (9 by maintainers)

Most upvoted comments

Hello @encryptblockr, true, this issue is seriously affecting both gophernotes and gomacro.

There have been various reports, which differ in their details and sometimes also in their cause, but the bulk is “importing third-party packages does not work anymore”.

Unluckily, it seems that it’s triggered by some change either in Go toolchain or in golang.org/x/tools/go/packages, i.e. the library used to inspect third-party packages.

Since it’s probably something outside gophernotes, fixing it may take some time.

(Ah, some of the issues were caused by missing or mismatched Go toolchains - that’s a different story).

As a workaround, @larsks found in https://github.com/cosmos72/gomacro/issues/146 that having at runtime a slightly different Go toolchain from the one used to compile gomacro (but it should be the same with gophernotes) fixes this issue.

That’s clearly a stop-gap, but it helps - at least until a permanent solution is found. For reference, this is what @larsks wrote in https://github.com/cosmos72/gomacro/issues/146:


The problem appears to be independent of the version of Go used to build gomacro; what matters is the version of Go in $PATH at runtime.

I built and installed gomacro using Go versions 1.19.4, 1.20, and 1.20.7 (installed from upstream release binaries from https://go.dev/dl/), and then tried a third party import with different versions of Go in $PATH.

Here’s the test script: [omitted]

And the results:

build: /home/lars/go/bin/gomacro: go1.19.4 runtime: 1.19.4 status: SUCCESS [i.e. can import third-party packages] build: /home/lars/go/bin/gomacro: go1.19.4 runtime: 1.20 status: SUCCESS build: /home/lars/go/bin/gomacro: go1.19.4 runtime: 1.20.7 status: SUCCESS build: /home/lars/go/bin/gomacro: go1.20 runtime: 1.19.4 status: SUCCESS build: /home/lars/go/bin/gomacro: go1.20 runtime: 1.20 status: FAILED [i.e. importing third-party packages fails] build: /home/lars/go/bin/gomacro: go1.20 runtime: 1.20.7 status: SUCCESS build: /home/lars/go/bin/gomacro: go1.20.7 runtime: 1.19.4 status: SUCCESS build: /home/lars/go/bin/gomacro: go1.20.7 runtime: 1.20 status: SUCCESS build: /home/lars/go/bin/gomacro: go1.20.7 runtime: 1.20.7 status: FAILED

Which are…weird. For anything more recent than 1.19.4, the import fails when the runtime version matches the build version.


@andys0975 have you solved this problem. I have this problem too, It picks the standard library packages but it doesn’t pick the third-party drivers.

Good 😃

A posteriori, this seems to have the same underlying cause as gophernotes issue #261 and gomacro issue #146 so fixing them 4 months ago fixed this one too.

The only missing step (on my TO DO list) is releasing a new gophernotes version, that would let users to simply

go install github.com/gopherdata/gophernotes

because at the moment they need

go install github.com/gopherdata/gophernotes@latest