diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e1998a..171ea63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Add description and website to help command - Fix Github Actions tests workflow on newer versions of Ubuntu +- Fix g not activating selected version when system one is available ## 0.9.1 - 2022-10-23 diff --git a/bin/g b/bin/g index a9f04c8..ec208f7 100755 --- a/bin/g +++ b/bin/g @@ -588,24 +588,22 @@ set_version() { error_and_abort "Version $version is not available. Use 'g install $version' to install it." fi - if [ "$version" != "$active" ]; then - if [ ! -e "$dir/g.lock" ]; then - for file in "$dir/"*; do - if [ -L "${GOROOT:?}/$(basename "$file")" ]; then - rm "${GOROOT:?}/$(basename "$file")" - elif [ -e "${GOROOT:?}/$(basename "$file")" ]; then - # enable seamless upgrade to symlink behavior - rm -rf "${GOROOT:?}/$(basename "$file")" - fi - ln -sf "$file" "${GOROOT:?}/$(basename "$file")" - done + if [ ! -e "$dir/g.lock" ]; then + for file in "$dir/"*; do + if [ -L "${GOROOT:?}/$(basename "$file")" ]; then + rm "${GOROOT:?}/$(basename "$file")" + elif [ -e "${GOROOT:?}/$(basename "$file")" ]; then + # enable seamless upgrade to symlink behavior + rm -rf "${GOROOT:?}/$(basename "$file")" + fi + ln -sf "$file" "${GOROOT:?}/$(basename "$file")" + done - for file in "$dir/bin/"*; do - ln -sf "$GOROOT/bin/$(basename "$file")" "$GOPATH/bin/" - done - else - error_and_abort "version $version installation might be corrupted" - fi + for file in "$dir/bin/"*; do + ln -sf "$GOROOT/bin/$(basename "$file")" "$GOPATH/bin/" + done + else + error_and_abort "version $version installation might be corrupted" fi }