magefile / mage

a Make/rake-like dev tool using Go

Home Page:https://magefile.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LTSBug: Installation failure under Ubuntu WSL under Windows 10

mykael22000 opened this issue · comments

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

  • Mage Version:
~/go/bin$ ./mage --version
Mage Build Tool v1.15.0-2-gc97c205
Build Date: 2023-11-09T09:30:48+08:00
Commit: c97c205
built with: go1.13.8
  • OS:
 Ubuntu 20.04.6 LTS (GNU/Linux 4.4.0-19041-Microsoft x86_64)
Under WLS under Windows 10 Pro

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.

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:

  • You are trying to install into the system folder, in which case we have no permissions and should not go on
  • You are trying to install in your home go path but that does not exist, in which case you might need a bit more configuration to do (we could mask other issues if we create the whole folder path)
  • You are pointing to the right path and we can proceed, creating bin folder if necessary but that is it.