Skip to content

gvm use fails with "command not found: -e": scripts/env/use never sources scripts/functions, leaving $HEXDUMP_PATH and friends empty #548

Description

@danish-a1

Summary

Using gvm use in an interactive shell floods the terminal with:

gvm_pseudohash_encode:25: command not found: -e

(in bash the same defect surfaces as -e: command not found, and for other helpers as -1: command not found, -v: command not found, etc.)

Root cause

scripts/function/tools defines LS_PATH, TR_PATH, SED_PATH, GREP_PATH, EGREP_PATH, SORT_PATH, HEAD_PATH and HEXDUMP_PATH. It is loaded only by scripts/functions, which iterates scripts/function/*.

scripts/env/use and scripts/env/pkgset-use never source scripts/functions — they only source _bash_pseudo_hash and _shell_compat:

https://github.com/moovweb/gvm/blob/master/scripts/env/use#L1-L4

So every tool variable is empty on those code paths, and each command loses its argv[0]:

  • scripts/function/_bash_pseudo_hash:289echo -n "$__char" | $HEXDUMP_PATH -e '1 1 "!%02x"' runs -e as the command
  • scripts/env/use:201, scripts/env/pkgset-use:191,223,224$LS_PATH -1 ... | $SORT_PATH | $GREP_PATH ... | $HEAD_PATH -n 1
  • scripts/function/gvm_export_path:3$TR_PATH, $GREP_PATH, $EGREP_PATH, $SED_PATH
  • scripts/function/gvm_environment_sanitize:7$SED_PATH

zsh reports the error at the enclosing case statement (line 25 of the function), which is why the message points at a line with no command in it.

Second, related bug

scripts/templates/binary:2 sources a path that does not exist:

. "$GVM_ROOT/scripts/functions/tools"

The directory is scripts/function (singular); scripts/functions is a file. Generated binary wrappers therefore always run with an empty $GREP_PATH on line 3.

Reproduce

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source ~/.gvm/scripts/gvm
gvm install go1.21.0 -B
gvm use go1.21.0

Environment: macOS 15 (Darwin 25.6.0), arm64, zsh 5.9 and bash 3.2/5.x, gvm 1.0.22.

Fix

Source scripts/functions from scripts/env/use and scripts/env/pkgset-use, correct the scripts/functions/tools path in scripts/templates/binary, and add ${VAR:-tool} fallbacks in the _-prefixed files that are documented as standalone-sourceable.

Happy to open a PR with this.

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