moovweb / gvm

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

Installing go1.20.2 line 85: go: command not found #425

Open jedrekdomanski opened 1 year ago

jedrekdomanski commented 1 year ago

I tried to install the latest version go1.20.2 and get the following error

go1.20.2
Downloading Go source...
Installing go1.20.2...
go1.20.2 /Users/jedrek/.gvm/archive/go /Users/jedrek/.gvm/gos/go1.20.2
 * Compiling...
/Users/jedrek/.gvm/scripts/install: line 85: go: command not found
ERROR: Failed to compile. Check the logs at /Users/jedrek/.gvm/logs/go-go1.20.2-compile.log
ERROR: Failed to use installed version

I tried to debug it and it looks like the source code is not copied from $GO_CACHE_PATH to $GO_INSTALL_ROOT

ls -l $GO_CACHE_PATH

ls -l $GO_CACHE_PATH
total 56
-rw-r--r--    1 jedrek  staff   1339 Mar 17 11:59 CONTRIBUTING.md
-rw-r--r--    1 jedrek  staff   1479 Mar 17 11:59 LICENSE
-rw-r--r--    1 jedrek  staff   1303 Mar 17 11:59 PATENTS
-rw-r--r--    1 jedrek  staff   1455 Mar 17 11:59 README.md
-rw-r--r--    1 jedrek  staff    419 Mar 17 11:59 SECURITY.md
drwxr-xr-x   26 jedrek  staff    832 Mar 17 11:59 api
-rw-r--r--    1 jedrek  staff     15 Mar 17 11:59 codereview.cfg
drwxr-xr-x    7 jedrek  staff    224 Mar 17 11:59 doc
-rw-r--r--    1 jedrek  staff    368 Mar 17 11:59 go.env
drwxr-xr-x    3 jedrek  staff     96 Mar 17 11:59 lib
drwxr-xr-x   13 jedrek  staff    416 Mar 17 11:59 misc
drwxr-xr-x   72 jedrek  staff   2304 Mar 17 11:59 src
drwxr-xr-x  356 jedrek  staff  11392 Mar 17 11:59 test
ls -l ~/.gvm/gos
total 0

The $version, $GO_CACHE_PATH and $GO_INSTALL_ROOT is there, echoing proves it

copy_source() {
    echo "$version" "$GO_CACHE_PATH" "$GO_INSTALL_ROOT"
    git clone -b "$version" "$GO_CACHE_PATH" "$GO_INSTALL_ROOT" >> "$GVM_ROOT/logs/go-$GO_NAME-install.log" 2>&1 ||
        display_fatal "Couldn't copy source to target folder. Check the logs $GVM_ROOT/logs/go-$GO_NAME-install.log"
}

prints

go1.20.2 /Users/jedrek/.gvm/archive/go /Users/jedrek/.gvm/gos/go1.20.2

The script fails at

[ -z "$GOROOT_BOOTSTRAP" ] && export GOROOT_BOOTSTRAP=$(go env GOROOT)

I'm not sure why the source code is not copied over to the .gvm/gos The logs say

# go-go1.20.2-compile.log

ERROR: Cannot find /Users/jedrek/go1.4/bin/go.
Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.17.13.
Krueladin commented 1 year ago

I can see that you're currently using go1.4. I was on something like go1.10. I had a similar issue when I attempted to get the latest version earlier today and I had to install an intermediate package (go1.17).

gvm install go1.17
gvm use go1.17

Then followed by the version I wanted

gvm install go.1.20
gvm use go1.20

This seemed to resolve any issues.

jedrekdomanski commented 1 year ago

I can see that you're currently using go1.4. I was on something like go1.10. I had a similar issue when I attempted to get the latest version earlier today and I had to install an intermediate package (go1.17).


gvm install go1.17

gvm use go1.17

Then followed by the version I wanted


gvm install go.1.20

gvm use go1.20

This seemed to resolve any issues.

I am running a MaOS and never installed any go version before and in fact I don't have any go versions installed at the moment.

Krueladin commented 1 year ago

Oh I see. I misread the error message. Looks like all you need to do is add the -B flag. I repro-ed on a clean docker image and tried a different command - leading to resolution. image image

So use the binary install: gvm install go1.20 -B followed by gvm use go 1.20

And if you haven't already, make sure to install the recommended packages first.

wakaryry commented 1 year ago

if use -B, got ERROR: Binary Go unavailable for this platform

DrkCoater commented 1 year ago

Oh I see. I misread the error message. Looks like all you need to do is add the -B flag. I repro-ed on a clean docker image and tried a different command - leading to resolution. image image

So use the binary install: gvm install go1.20 -B followed by gvm use go 1.20

And if you haven't already, make sure to install the recommended packages first.

I was on Ubuntu 22, had the same issue. No problem on my MacOS. The '-B' option you suggested worked for me, thank you so much!

wakaryry commented 1 year ago

suggest: goenv

ankitcharolia commented 11 months ago

@wakaryry @DrkCoater @jedrekdomanski @Krueladin kindly try this GO Version Manager: https://github.com/ankitcharolia/goenv