goenv icon indicating copy to clipboard operation
goenv copied to clipboard

If ls or other system utilities are customized, goenv fails

Open netik opened this issue 1 year ago • 1 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 avatar Dec 25 '23 23:12 netik

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

ankitcharolia avatar Jan 02 '24 11:01 ankitcharolia

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

ChronosMasterOfAllTime avatar Mar 06 '24 18:03 ChronosMasterOfAllTime

Fixed in v2.1.13

ChronosMasterOfAllTime avatar Mar 06 '24 20:03 ChronosMasterOfAllTime