Summary
go install github.com/please-build/puku/cmd/puku@latest fails because knownimports/go_root_packages is generated by a Please genrule and is not committed to the repository. Since go:embed requires the file to exist at build time, the standard Go toolchain cannot build puku without manually generating it first.
The README documents go install as the recommended installation method:
$ go install github.com/please-build/puku/cmd/puku
Steps to reproduce
cd "$(mktemp -d /tmp/puku-bug.XXXXXX)"
go version
go install github.com/please-build/puku/cmd/puku@latest
Actual result
go version go1.26.1 darwin/arm64
knownimports/known_imports.go:11:12: pattern go_root_packages: no matching files found
Expected result
The command installs puku successfully.
Root cause
knownimports/known_imports.go:11 embeds the file go_root_packages:
//go:embed go_root_packages
var goRootPkgs string
This file is generated by the genrule in knownimports/BUILD, which lists all standard library packages from //third_party/go:std. The file is not checked into version control, so any build outside of Please (including go install, go build, and CI pipelines using the Go toolchain) fails.
Current workaround
git clone https://github.com/please-build/puku.git
cd puku
go list std > knownimports/go_root_packages
go install ./cmd/puku
Suggested fix
A few options, in rough order of simplicity:
-
Commit the generated file — check go_root_packages into the repo. It only needs periodic updates when new Go versions add standard library packages, and the runtime fallback in IsInGoRoot already handles versions newer than the list.
-
Add a go:generate directive — e.g. //go:generate sh -c "go list std > go_root_packages" in known_imports.go, and document go generate ./... as a prerequisite. This keeps the file out of version control but gives Go-toolchain users a clear path.
-
Generate at init time — replace the go:embed with a call to exec.Command("go", "list", "std") in init(). This removes the build-time dependency entirely but adds a runtime dependency on the go binary being in PATH.
Option 1 is the lowest friction — it restores go install @latest compatibility with no workflow changes for Please users.
Environment
- puku v1.17.1 (
b7a1547)
- Go 1.26.1 darwin/arm64
Summary
go install github.com/please-build/puku/cmd/puku@latestfails becauseknownimports/go_root_packagesis generated by a Pleasegenruleand is not committed to the repository. Sincego:embedrequires the file to exist at build time, the standard Go toolchain cannot build puku without manually generating it first.The README documents
go installas the recommended installation method:Steps to reproduce
Actual result
Expected result
The command installs
pukusuccessfully.Root cause
knownimports/known_imports.go:11embeds the filego_root_packages:This file is generated by the
genruleinknownimports/BUILD, which lists all standard library packages from//third_party/go:std. The file is not checked into version control, so any build outside of Please (includinggo install,go build, and CI pipelines using the Go toolchain) fails.Current workaround
Suggested fix
A few options, in rough order of simplicity:
Commit the generated file — check
go_root_packagesinto the repo. It only needs periodic updates when new Go versions add standard library packages, and the runtime fallback inIsInGoRootalready handles versions newer than the list.Add a
go:generatedirective — e.g.//go:generate sh -c "go list std > go_root_packages"inknown_imports.go, and documentgo generate ./...as a prerequisite. This keeps the file out of version control but gives Go-toolchain users a clear path.Generate at init time — replace the
go:embedwith a call toexec.Command("go", "list", "std")ininit(). This removes the build-time dependency entirely but adds a runtime dependency on thegobinary being inPATH.Option 1 is the lowest friction — it restores
go install @latestcompatibility with no workflow changes for Please users.Environment
b7a1547)