kitops icon indicating copy to clipboard operation
kitops copied to clipboard

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

Open Goyamjain06 opened this issue 3 months ago • 1 comments

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.

Goyamjain06 avatar Sep 03 '26 03:09 Goyamjain06

I'd like to work on this one — happy to add a preflight check for required tools (pnpm, sha256sum/shasum, curl, tar) and a set -e guard, plus update CONTRIBUTING.md's Prerequisites section to mention pnpm. Will open a PR shortly.

Goyamjain06 avatar Sep 03 '26 03:09 Goyamjain06