Skip to content

go install fails: missing go:embed file go_root_packages #148

Description

@sean-

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:

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

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions