moovweb / gvm

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

ERROR: Couldn't remove pkgsets #319

Open chrisduong opened 5 years ago

chrisduong commented 5 years ago

Hi,

I tried to remove old Go pkgsets, I get the Error.

❯ gvm uninstall go1.11.1
ERROR: Couldn't remove pkgsets

❯ \ls -G .gvm/gos/
go1.11.1 go1.11.4 system
nezorflame commented 5 years ago

It can't remove pkgsets because new Go modules folder pkg is protected, so you have to be root to delete it. You need to first clean the mod cache by this sequence, then switch to your other Go version and try to uninstall again (make sure to do this outside of any Go source folder):

gvm use go1.11.1
go clean -modcache
gvm use go1.11.4
gvm uninstall go1.11.1

You could also use sudo to manually delete pkgset ~/.gvm/pkgsets/go1.11.1, then repeat command gvm uninstall go1.11.1.

mcandre commented 3 years ago

This step is something that gvm could reasonably be expected to automate on behalf of the user.

austincunningham commented 1 year ago

go clean -modcache works for versions older than go1.17, but seem to fail on go1.17.6 and go1.17

gvm use go1.17
Now using version go1.17
go clean -modcache
gvm use go1.18      
Now using version go1.18
gvm uninstall go1.17  
ERROR: Couldn't remove pkgsets

manually deleting the packsets works in ~/.gvm/pkgsets/go1.17 and ~/.gvm/pkgsets/go1.17.6

o-az commented 1 year ago

added this to my shell config so I don't have to revisit this issue every release

function update-go() {
  CURRENT_VERSION=$(go version | awk '{print $3}')
  LATEST_VERSION=$(curl -s https://golang.org/VERSION?m=text)
  if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
    echo "You are already on the latest version"
    return
  fi
  go clean -modcache
  gvm install $LATEST_VERSION
  gvm use $LATEST_VERSION --default
  gvm uninstall $CURRENT_VERSION

  echo "Go updated from $CURRENT_VERSION to $LATEST_VERSION"
}
lucaspar commented 10 months ago

@o-az I had to change latest to this instead:

LATEST_VERSION=$(curl -s https://go.dev/VERSION?m=text | head -n 1 | awk '{print $1}')

also, it's probably good to add a gvm update step before attempting to install the latest with gvm.

netixx commented 9 months ago

I did chmod -R u+w ~/.gvm/pkgsets/go1.X and then gvm uninstall worked. No need for sudo this way (and no need to go clean either), although it's less clean, I guess it doesn't matter because we are uninstalling anyways...