Skip to content

Upgrading from go_get: mage binary #259

@sean-

Description

@sean-

I'm struggling mightily with getting the mage tool built using the new regime. I'm coming from:

go_get(
    name = "mage",
    binary = True,
    get = [],
    install = ["github.com/magefile/mage"],
    deps = [":mage_lib"],
)

go_get(
    name = "mage_lib",
    get = "github.com/magefile/mage",
    install = [
        "internal",
        "mage",
        "mg",
        "parse",
        "sh",
        "target",
    ],
    revision = "aedfce64c122eef47009b7f80c9771044753215d",  # v1.8.0
)

And trying to upgrade to:

go_module(
    name = "mage_module",
    module = "github.com/magefile/mage",
    version = "v1.15.0",
    install = [
        "github.com/magefile/mage",
    ],
)

go_binary(
    name = "mage",
    srcs = ["src/github.com/magefile/main.go"],
    deps = [":mage_module"],
)

Results in:

$ plz build
Build stopped after 120ms. 1 target failed:
    //third_party/go:_mage#lib_pkg_info
cannot calculate hash for third_party/go/src/github.com/magefile/main.go: file does not exist

Or:

go_binary(
     name = "mage",
     srcs = ["github.com_magefile_mage/main.go"],
     deps = [
         "///third_party/go/github.com_magefile_mage//main",
         #":mage_module",
     ],
 )

Which results in:

✦ ➜ plz build
Build stopped after 90ms. 1 target failed:
    ///third_party/go/github.com_magefile_mage//main:main
subrepo third_party/go/github.com_magefile_mage is not defined in this package yet. It must appear before it is used by //third_party/go:mage
    ///third_party/go/github.com_magefile_mage//main:main
subrepo third_party/go/github.com_magefile_mage is not defined in this package yet. It must appear before it is used by //third_party/go:mage
    ///third_party/go/github.com_magefile_mage//main:main
subrepo third_party/go/github.com_magefile_mage is not defined in this package yet. It must appear before it is used by //third_party/go:mage

or the other commented-out variant:

 ➜ plz build --shell --debug //third_party/go:mage
11:11:01.203   ERROR: //third_party/go:_mage#lib_pkg_info failed:
cannot calculate hash for third_party/go/github.com_magefile_mage/main.go: file does not exist
Build stopped after 30ms. 1 target failed:
    //third_party/go:_mage#lib_pkg_info
cannot calculate hash for third_party/go/github.com_magefile_mage/main.go: file does not exist

This feels like it should be dead simple, but I'm struggling because I also can't easily investigate the build environment because the --shell is failing to build.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions