Skip to content

gen_common.sh fails silently when pnpm is missing, surfaces a confusing unrelated error #1275

Description

@Goyamjain06

Description

Running go generate ./... invokes pkg/lib/harness/generated/gen_common.sh, which calls pnpm install and pnpm run build to build the harness UI. If pnpm is not installed, these commands fail, but the script has no set -e and does not check the exit status. Execution continues into the compress step, which then fails with a confusing, seemingly unrelated error:

./gen_common.sh: line 12: pnpm: command not found
./gen_common.sh: line 13: pnpm: command not found
Compressing ../../../../frontend/dev-mode/dist to ../ui.tar.gz
tar: could not chdir to '../../../../frontend/dev-mode/dist'

A new contributor debugging the tar error has no clear path back to "install pnpm" — the real cause is buried two commands earlier in the log.

Expected Behavior

The script should fail fast with a clear, actionable error message (e.g. "pnpm is required but was not found on PATH. Install it: https://pnpm.io/installation") as soon as a required tool is missing, rather than continuing and producing a misleading downstream error.

Proposed Solution

  • Add set -e (or explicit exit-code checks) to gen_common.sh to stop execution on the first failure.
  • Add a preflight check at the top of the script that verifies required tools (pnpm, sha256sum/shasum, curl, tar) are available on PATH, and print a clear installation hint if not.
  • Optionally note in CONTRIBUTING.md that pnpm is a required prerequisite for go generate ./... (it is currently missing from the Prerequisites section, which only lists Go and Git).

Additional Notes

  • The script uses #!/bin/sh with pushd/popd, which are bash-only builtins and undefined in POSIX sh (e.g. dash on many Linux systems). This should probably be #!/bin/bash or rewritten to avoid pushd/popd for portability.
  • Happy to submit a PR for this if assigned.

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