go-nv / goenv

:blue_car: Like pyenv and rbenv, but for Go.

Home Page:https://github.com/go-nv/goenv

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

If ls or other system utilities are customized, goenv fails

netik opened this issue · comments

MacOS and many users frequently have ls customized in ways that break goenv.

For example when ls has -F turned on directories are listed with a trailing slash/ which breaks the fuzzy_match code in scripts/use

goenv should be agnostic about how LS functions, perhaps unsetting things like LSCOLORS and calling /bin/ls instead of trying to call ls without a path.

Right now I've patched this by adding modifying the use code to call

    fuzzy_match=$($LS_PATH -1 "$GVM_ROOT/gos" | $SORT_PATH | $GREP_PATH "$version" | $HEAD_PATH -n 1 | $GRE\
P_PATH "${version}")

    # strip trailing slashes                                                                                
    fuzzy_match=`echo $fuzzy_match | sed s^/$^^`

But this isn't a great solution.

@netik if you have time and want to submit a solution via PR I'd be fine with changing the behavior.

Fixed in v2.1.13