Skip to content

cmd/go: panic: LoadImport called with empty package path [recovered] when building source #67984

@MikeMitchellWebDev

Description

@MikeMitchellWebDev

Go version

go version go1.22.0 darwin/amd64

Output of go env in your module/workspace:

go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/mm/Library/Caches/go-build'
GOENV='/Users/mm/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/mm/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/mm/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='/usr/bin/clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/mm/go/src/github.com/MikeMitchellWebDev/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/5y/wtzzmjlj5v52pg7wr8ptbg_m0000gp/T/go-build434803499=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I tried to time how long it takes to build the Go source code (which I didn't alter at all) by running time ./make.bash from the src dir of the repository as the Go blog instructs. The first time it built successfully, and then I ran the same build command two other times and the build process failed each time

On another version of the Go source code (which I had, incidentally, altered minimally) running time ./make.bash ran successfully two times in a row.

What did you see happen?

1st time

time ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/amd64.

Installed Go for darwin/amd64 in /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3
Installed commands in /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/bin
*** You need to add /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/bin to your PATH.

real 10m14.007s
user 17m17.838s
sys 2m58.189s

2nd time

time ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/amd64.
panic: LoadImport called with empty package path [recovered]
panic: LoadImport called with empty package path

goroutine 1 [running]:
cmd/go/internal/load.(*preload).flush(0xc0006317f0)
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:1082 +0x74
panic({0x1442c00?, 0x1590cd0?})
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/runtime/panic.go:785 +0x132
cmd/go/internal/load.loadImport({0x1596200, 0x18462e0}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, 0x0, {0xc000dc263d, ...}, ...)
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:681 +0x13e5
cmd/go/internal/load.(*Package).load(0xc001860008, {0x1596200, 0x18462e0}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, {0xc0003ea97d, ...}, ...)
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:1969 +0x1a6e
cmd/go/internal/load.loadImport({0x1596200, 0x18462e0}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, 0xc0006317f0, {0xc0003ea97d, ...}, ...)
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:744 +0x52f
cmd/go/internal/load.PackagesAndErrors({0x1596200?, 0x18462e0?}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, {0xc0000220b0, 0x1, ...})
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:2837 +0xa0b
cmd/go/internal/work.runInstall({0x1596200, 0x18462e0}, 0xc00002a348?, {0xc0000220b0, 0x1, 0x1})
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/work/build.go:696 +0x1fd
main.invoke(0x181b380, {0xc0000220a0, 0x2, 0x2})
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/main.go:298 +0x6e3
main.main()
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/main.go:212 +0xabc
go tool dist: FAILED: /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/pkg/tool/darwin_amd64/go_bootstrap install std: exit status 2

real 7m33.434s
user 9m49.533s
sys 1m48.451s

3rd time

time ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/amd64.
panic: LoadImport called with empty package path [recovered]
panic: LoadImport called with empty package path

goroutine 1 [running]:
cmd/go/internal/load.(*preload).flush(0xc000036f20)
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:1082 +0x74
panic({0x1442c00?, 0x1590cd0?})
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/runtime/panic.go:785 +0x132
cmd/go/internal/load.loadImport({0x1596200, 0x18462e0}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, 0x0, {0x65db63d, ...}, ...)
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:681 +0x13e5
cmd/go/internal/load.(*Package).load(0xc0016f0008, {0x1596200, 0x18462e0}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, {0xc0003de19d, ...}, ...)
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:1969 +0x1a6e
cmd/go/internal/load.loadImport({0x1596200, 0x18462e0}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, 0xc000036f20, {0xc0003de19d, ...}, ...)
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:744 +0x52f
cmd/go/internal/load.PackagesAndErrors({0x1596200?, 0x18462e0?}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, {0xc0000a20b0, 0x1, ...})
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:2837 +0xa0b
cmd/go/internal/work.runInstall({0x1596200, 0x18462e0}, 0xc0000b42d0?, {0xc0000a20b0, 0x1, 0x1})
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/work/build.go:696 +0x1fd
main.invoke(0x181b380, {0xc0000a20a0, 0x2, 0x2})
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/main.go:298 +0x6e3
main.main()
/Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/main.go:212 +0xabc
go tool dist: FAILED: /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/pkg/tool/darwin_amd64/go_bootstrap install std: exit status 2

real 4m52.105s
user 8m45.084s
sys 1m30.284s
Michaels-MacBook-Pro-3:src mm$ go bug
go: downloading go1.23 (darwin/amd64)
go: download go1.23 for darwin/amd64: toolchain not available
Michaels-MacBook-Pro-3:src mm$ go env
go: downloading go1.23 (darwin/amd64)
go: download go1.23 for darwin/amd64: toolchain not available

What did you expect to see?

I expected the build to run successfully each time (as it did on the source code that I did alter)


Michaels-MacBook-Pro-3:src mm$ time ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/amd64.
---
Installed Go for darwin/amd64 in /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_2
Installed commands in /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_2/bin
*** You need to add /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_2/bin to your PATH.

real	5m40.768s
user	9m55.416s
sys	1m43.497s
Michaels-MacBook-Pro-3:src mm$ time ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/amd64.
---
Installed Go for darwin/amd64 in /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_2
Installed commands in /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_2/bin
*** You need to add /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_2/bin to your PATH.

real	5m30.650s
user	9m22.241s
sys	1m37.025s

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeGoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions