mage: `mage -version` does not return version information

Currently the output of mage -version is:

Mage Build Tool 
Build Date: <not set>
Commit: <not set>

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Right now, mage -version is only populated if you use the (downloaded) binary version of mage, or if you build mage with mage build.

There’s no way to hard code the specific commit revision in the sourcecode, but I could hard code the major version number, which would at least give you an idea of what you’re running.

I just merged a change that’ll make the mage build target use -a, so it’ll do the right thing. There’s also now better installation instructions, and a bootstrap.go file that you can go run for first time users that don’t have mage yet.

Thanks for reporting this, you’ve made the first-time experience a lot better because of it 😃

Right now, mage -version is only populated if […] you build mage with mage build.

$ go get -u -v github.com/magefile/mage
github.com/magefile/mage (download)
github.com/magefile/mage/types
github.com/magefile/mage/mg
github.com/magefile/mage/parse
github.com/magefile/mage/sh
github.com/magefile/mage/mage
github.com/magefile/mage

$ cd ~/Go/src/github.com/magefile/mage
$ mage build
$ mage -version
Mage Build Tool v2
Build Date: <not set>
Commit: <not set>

Build and commit fields are still unset ⁉️ But modification time of mage binary in "${GOPATH}/bin" hasn’t changed a bit so I would suspect that something is not quite working as expected in the build process…

$ mage -v build
Running target: Build
exec: git rev-parse --short HEAD
exec: git describe --tags
exec: go install -ldflags=-X "github.com/magefile/mage/mage.timestamp=2017-10-25T11:21:46+02:00" -X "github.com/magefile/mage/mage.commitHash=ab3ca2f" -X "github.com/magefile/mage/mage.gitTag=v2.0.1" github.com/magefile/mage

$ git rev-parse --short HEAD
ab3ca2f

$ git describe --tags
v2.0.1

$ go install -ldflags=-X "github.com/magefile/mage/mage.timestamp=2017-10-25T11:21:46+02:00" -X "github.com/magefile/mage/mage.commitHash=ab3ca2f" -X "github.com/magefile/mage/mage.gitTag=v2.0.1" github.com/magefile/mage
can't load package: package github.com/magefile/mage/mage.timestamp=2017-10-25T11:21:46+02:00: cannot find package "github.com/magefile/mage/mage.timestamp=2017-10-25T11:21:46+02:00" in any of:
        C:\Go\src\github.com\magefile\mage\mage.timestamp=2017-10-25T11:21:46+02:00 (from $GOROOT)
        C:\Documents and Settings\Michaël\Go\src\github.com\magefile\mage\mage.timestamp=2017-10-25T11:21:46+02:00 (from $GOPATH)
can't load package: package -X: cannot find package "-X" in any of:
        C:\Go\src\-X (from $GOROOT)
        C:\Documents and Settings\Michaël\Go\src\-X (from $GOPATH)
can't load package: package github.com/magefile/mage/mage.commitHash=ab3ca2f: cannot find package "github.com/magefile/mage/mage.commitHash=ab3ca2f" in any of:
        C:\Go\src\github.com\magefile\mage\mage.commitHash=ab3ca2f (from $GOROOT)
        C:\Documents and Settings\Michaël\Go\src\github.com\magefile\mage\mage.commitHash=ab3ca2f (from $GOPATH)
can't load package: package github.com/magefile/mage/mage.gitTag=v2.0.1: cannot find package "github.com/magefile/mage/mage.gitTag=v2.0.1" in any of:
        C:\Go\src\github.com\magefile\mage\mage.gitTag=v2.0.1 (from $GOROOT)
        C:\Documents and Settings\Michaël\Go\src\github.com\magefile\mage\mage.gitTag=v2.0.1 (from $GOPATH)

Looks like there is a problem with the -ldflags param value assignment 🐛