get-helm-3 install script fails if HELM_INSTALL_DIR is not in $PATH during non-interactive execution
What happened?
When running the official Helm installation script ( get-helm-3 ) in an environment where the target installation directory (like /usr/local/bin or a custom HELM_INSTALL_DIR ) is not present in the current $PATH environment variable, the script fails and exits with status code 1 .
This occurs even though the script successfully downloads the archive, extracts it, and moves the helm binary to the target directory. The failure happens in the final verification step ( testVersion() ), which checks for the availability of the command using command -v helm . In non-interactive or minimal guest VM environments (such as Kubernetes minikube guest VMs), /usr/local/bin is frequently omitted from the default shell path, leading to this failure.
What did you expect to happen?
The script should successfully complete and exit with status code 0 when the binary is successfully copied to the target directory.
Instead of verifying the command globally using command -v helm (which assumes the destination directory is already on the shell path), the script's testVersion() function should check the executable binary at its actual
installation location (e.g. by running "$HELM_INSTALL_DIR/helm version" or checking [ -x "$HELM_INSTALL_DIR/helm" ] ).
How can we reproduce it (as minimally and precisely as possible)?
You can reproduce this on any Linux machine by running the installation script in a shell environment where the installation directory is explicitly removed from $PATH:
# 1. Download the installer script
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
# 2. Run it in an environment where /usr/local/bin is excluded from PATH
env PATH="/usr/bin:/bin" ./get_helm.shObserved output:
helm not found. Is /usr/local/bin on your $PATH?Exit code:
echo $?
# Output: 1Suggested Fix:
Change the verification check intestVersion()from:
if ! command -v "$BINARY_NAME" &> /dev/null; then
to run the binary directly at its installation path:if [ ! -x "$HELM_INSTALL_DIR/$BINARY_NAME" ]; then(Note: If you check /usr/local/bin/helm , you will see that the binary was actually successfully installed there, despite the script exit code).
Helm version
$ helm version
# N/A (Fails during installation process using get-helm-3)Kubernetes version
$ kubectl version
# N/A (Not related to Kubernetes version)
Source: helm/helm