go-nv / goenv

:blue_car: Like pyenv and rbenv, but for Go.
https://github.com/go-nv/goenv
MIT License
2.05k stars 245 forks source link

If ls or other system utilities are customized, goenv fails #358

Closed netik closed 6 months ago

netik commented 8 months ago

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.

ankitcharolia commented 8 months ago

@netik kindly try out this one: https://github.com/ankitcharolia/goenv

ChronosMasterOfAllTime commented 6 months ago

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

ChronosMasterOfAllTime commented 6 months ago

Fixed in v2.1.13