magefile / mage

a Make/rake-like dev tool using Go
https://magefile.org
Apache License 2.0
4.01k stars 250 forks source link

LTSBug: Installation failure under Ubuntu WSL under Windows 10 #486

Closed mykael22000 closed 7 months ago

mykael22000 commented 7 months ago

Bug Description Installation fails with an error about it being unable to create a go/bin directory.

What did you do? I'm setting my system up to be able to write Grafana plug-ins. Upgrade Ubuntu WLS, install a few things. https://grafana.com/developers/plugin-tools/.

Instructions for installing mage from https://magefile.org/ were:

git clone https://github.com/magefile/mage
cd mage
go run bootstrap.go

The final step failed:

~mage$:go run bootstrap.go
Running target: Install
exec: go "env" "GOBIN"
exec: go "env" "GOPATH"
Error: failed to create "/home/mik/go/bin": mkdir /home/mik/go/bin: no such file or directory
exit status 1

What did you expect to happen? I expected the install to work.

What actually happened? The install failed. I manually created the directory and ran it again - and this time it worked. The error may have been because mage was the first time I'd tried running go on the system.

It looks like there may be an issue with go set up, as the mage command does not work, unless I cd into the go/bin directory and invoke it directly as .mage. Given the mage install script looks like it's meant to handle this, I may have some more patching to do.

Environment

Additional context

As far as I know, the go run bootstrap.go ran under my user account, the same one I was able to successfully manually create the go/bin directory from, so the failure shouldn't have been an authorization issue.

perrito666 commented 7 months ago

So, this is, despite what it looks like, not a bug.

The relevant code for context:

    // specifically don't mkdirall, if you have an invalid gopath in the first
    // place, that's not on us to fix.
    if err := os.Mkdir(bin, 0700); err != nil && !os.IsExist(err) {
        return fmt.Errorf("failed to create %q: %v", bin, err)
    }

in this case bin is supposed to be $GOPATH/bin. The options here are: