andrewkroh / gvm

Go Version Manager (written in Go for cross-platform usability)
Apache License 2.0
186 stars 24 forks source link

Cannot use gvm in Ubuntu 20 in Google Cloud #44

Closed mdelapenya closed 2 years ago

mdelapenya commented 2 years ago

Hi! 👋 I'm not able to use GVM in Ubuntu-20.04 running on GCE

Steps to reproduce

Create a Ubuntu-20.04 instance on Google Cloud, then use the install scripts provided in README

export GVM_VERSION=0.3.2
mkdir -p ~/bin
curl -sL -o ~/bin/gvm https://github.com/andrewkroh/gvm/releases/download/v${GVM_VERSION}/gvm-linux-amd64
chmod +x ~/bin/gvm
PATH="$PATH:~/bin"
gvm v1.17
gvm: error: strconv.ParseBool: parsing "0.3.2": invalid syntax
gvm v1.17.6
gvm: error: strconv.ParseBool: parsing "0.3.2": invalid syntax
gvm 1.17.6
gvm: error: strconv.ParseBool: parsing "0.3.2": invalid syntax

Expected behaviour: GVM installs Go without errors Current behaviour: GVM fails with a ParseBool error

andrewkroh commented 2 years ago

What GVM version are you using?

andrewkroh commented 2 years ago

I haven't reproduced yet. I didn't try on GCP, but I did try in an ubuntu:20.04 container.

root@477272ae11a6:/# cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS"
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

root@477272ae11a6:/# echo $PATH
/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

root@477272ae11a6:/# gvm --version
v0.3.2

root@477272ae11a6:/# gvm -d v1.17.6
DEBU[0000] Using Go version 1.17.6                       package=main
DEBU[0000] Downloading file                              package=common url="https://storage.googleapis.com/golang/go1.17.6.linux-amd64.tar.gz"
DEBU[0006] Download complete                             file=/tmp/go1.17.6.linux.amd64364192017/go1.17.6.linux-amd64.tar.gz package=common size_bytes=134830580
export GOROOT="/root/.gvm/versions/go1.17.6.linux.amd64"
export PATH="/root/.gvm/versions/go1.17.6.linux.amd64/bin:$PATH"
mdelapenya commented 2 years ago

I tried with 0.3.2 and anything after 0.2.0, so my guess it's something on Google Cloud. I did try with same versions on my local Mac, and they worked

andrewkroh commented 2 years ago

I'll try it on GCP.

andrewkroh commented 2 years ago

@mdelapenya I tested on GCP Ubuntu 20.04 but had no issues. See below.

 $ gcloud compute instances create $USER-dev \
  --image-project=ubuntu-os-cloud \
  --image-family ubuntu-2004-lts \
  --zone us-central1-a \
  --machine-type=n1-standard-1 \
  --boot-disk-size=100GB

$ gcloud compute ssh --zone=us-central1-a $USER-dev

$ sudo curl -L "https://github.com/andrewkroh/gvm/releases/download/v0.3.2/gvm-linux-amd64" -o /usr/local/bin/gvm
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   652  100   652    0     0   3662      0 --:--:-- --:--:-- --:--:--  3642
100 9485k  100 9485k    0     0  21.7M      0 --:--:-- --:--:-- --:--:-- 21.7M

$ sudo chmod +x /usr/local/bin/gvm

$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS"
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

$ which gvm
/usr/local/bin/gvm

$ gvm --version
v0.3.2

$ gvm -d v1.17
DEBU[0000] Using Go version 1.17                         package=main
DEBU[0000] Downloading file                              package=common url="https://storage.googleapis.com/golang/go1.17.linux-amd64.tar.gz"
DEBU[0000] Download complete                             file=/tmp/go1.17.linux.amd64805127606/go1.17.linux-amd64.tar.gz package=common size_bytes=134787877
export GOROOT="/home/akroh/.gvm/versions/go1.17.linux.amd64"
export PATH="/home/akroh/.gvm/versions/go1.17.linux.amd64/bin:$PATH"

$ gvm -d v1.17.6
DEBU[0000] Using Go version 1.17.6                       package=main
DEBU[0000] Downloading file                              package=common url="https://storage.googleapis.com/golang/go1.17.6.linux-amd64.tar.gz"
DEBU[0000] Download complete                             file=/tmp/go1.17.6.linux.amd641864718803/go1.17.6.linux-amd64.tar.gz package=common size_bytes=134830580
export GOROOT="/home/akroh/.gvm/versions/go1.17.6.linux.amd64"
export PATH="/home/akroh/.gvm/versions/go1.17.6.linux.amd64/bin:$PATH"

$ gvm -d 1.17.6
DEBU[0000] Using Go version 1.17.6                       package=main
export GOROOT="/home/akroh/.gvm/versions/go1.17.6.linux.amd64"
export PATH="/home/akroh/.gvm/versions/go1.17.6.linux.amd64/bin:$PATH"
andrewkroh commented 2 years ago

Oh, setting GVM_VERSION is causing the problem.

andrewkroh commented 2 years ago

gvm has a boolean flag to output the version. By default any flags can be set via env var by using GVM_<flag>. So the app is trying to parse GVM_VERSION as a boolean to set that flag.

https://github.com/andrewkroh/gvm/blob/76296752ef366391fdf1e8cf87afa040031ea454/cmd/gvm/gvm.go#L68

So I recommend to not use the GVM_ namespace to hold the installation version. Maybe SETUP_GVM_VERSION 😄 .

andrewkroh commented 2 years ago

I have added documentation about this behavior to the README and usage text for gvm -h.

mdelapenya commented 2 years ago

Ahhh cool that you found it and helped to improve the docs. Thanks!