moovweb / gvm

Go Version Manager
http://github.com/moovweb/gvm
MIT License
9.88k stars 520 forks source link

Which GVM echoes out script instead of location #422

Open Sylk opened 1 year ago

Sylk commented 1 year ago

I'm running the command which gvm after installing completely but I get this output.

❯ which gvm
gvm () {
        if [[ "$GVM_ROOT" == "" ]]
        then
                display_error "GVM_ROOT not set. Please source \$GVM_ROOT/scripts/gvm"
                return $?
        fi
        if [[ -d $GVM_ROOT/.git ]]
        then
                mv "$GVM_ROOT/.git" "$GVM_ROOT/git.bak" || display_error "Failed to move git info out of the way"
        fi
        if [[ ! -d $GVM_ROOT ]]
        then
                display_error "GVM_ROOT does not exist. Please reinstall GVM"
                return $?
        fi
        mkdir -p "$GVM_ROOT/logs" > /dev/null 2>&1
        mkdir -p "$GVM_ROOT/gos" > /dev/null 2>&1
        mkdir -p "$GVM_ROOT/archive" > /dev/null 2>&1
        mkdir -p "$GVM_ROOT/archive/package" > /dev/null 2>&1
        mkdir -p "$GVM_ROOT/environments" > /dev/null 2>&1
        if [[ "$1" == "use" ]]
        then
                . "$GVM_ROOT/scripts/env/use"
                shift
                gvm_use "$@"
        elif [[ "$1" == "implode" ]]
        then
                . "$GVM_ROOT/scripts/env/implode"
                gvm_implode
        elif [[ "$1" == "pkgset" ]] && [[ "$2" == "use" ]]
        then
                . "$GVM_ROOT/scripts/env/pkgset-use"
                shift
                shift
                gvm_pkgset_use "$@"
        else
                "$GVM_ROOT/bin/gvm" "$@"
        fi
}

I don't know if this is related to the way that the installation process is described on linux but this feels quite wrong.

DeanFoley commented 1 year ago

Was hoping there'd be a fun thing to try to fix here but: this is what which seems to do with this and similar programs where you install them by adding to your ~/.zshrc or ~/.bashrc

whereis gvm                                                                                                                                                                                                                             
gvm: /Users/dean/.gvm/bin/gvm

If you have nvm installed you can see a similar phenomenon with which nvm (I won't share the output because it's absolutely massive). If you have any alias's configured in your .bashrc or .zshrc, see what happens when you run a which against it.

ankitcharolia commented 11 months ago

@Sylk @DeanFoley kindly try this GO Version Manager: https://github.com/ankitcharolia/goenv