rules_docker icon indicating copy to clipboard operation
rules_docker copied to clipboard

Error running `container_push`

Open mattjs opened this issue 3 years ago • 4 comments

🐞 bug report

Affected Rule

container_push

Is this a regression?

Worked on 0.12.1

Description

When running container_push

ERROR: .../BUILD:51:15: every rule of type container_push_ implicitly depends upon the target '@io_bazel_rules_docker//container/go/cmd/pusher:pusher', but this target could not be found because of: error loading package '@io_bazel_rules_docker//container/go/cmd/pusher': at /private/var/tmp/_bazel_matthew/7b254c56ef02c3a8ccbb58cecfd5fda6/external/bazel_gazelle/def.bzl:34:5: at /private/var/tmp/_bazel_matthew/7b254c56ef02c3a8ccbb58cecfd5fda6/external/bazel_gazelle/internal/gazelle_binary.bzl:22:5: Label '@io_bazel_rules_go//go/private:rules/aspect.bzl' is invalid because '@io_bazel_rules_go//go/private/rules' is a subpackage; perhaps you meant to put the colon here: '@io_bazel_rules_go//go/private/rules:aspect.bzl'?

🌍 Your Environment

Operating System:

Mac

Output of bazel version:

Build label: 5.0.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Jan 19 14:15:55 2022 (1642601755)
Build timestamp: 1642601755
Build timestamp as int: 1642601755

Rules_docker version:

0.23.0

mattjs avatar Feb 06 '22 01:02 mattjs

Getting the same issue on with Bazel 4.2.2.

Tried downgrading to rules 0.12.1 and still get the same issue.

marksmithson avatar Feb 15 '22 17:02 marksmithson

found this issue that seems to be related, https://github.com/bazelbuild/rules_docker/issues/943

JackTreble avatar Feb 15 '22 17:02 JackTreble

You're likely running into a conflict between the version of rules_go and bazel-gazelle. Assuming you're using the recommended setup, rules_docker will implicitly load any repositories that haven't been loaded already in your WORKSPACE, and so if you only pre-load one of them they're likely to not be in sync.

The easiest path forward is to explicitly load both of them prior to instantiating rules_docker.

dastbe avatar Mar 17 '22 21:03 dastbe

I can confirm that @dastbe's suggestion works. With the following snippet, container_push rules will start working again.

http_archive(
    name = "io_bazel_rules_go",
    sha256 = "f2dcd210c7095febe54b804bb1cd3a58fe8435a909db2ec04e31542631cf715c",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip",
        "https://github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip",
    ],
)

http_archive(
    name = "bazel_gazelle",
    sha256 = "5982e5463f171da99e3bdaeff8c0f48283a7a5f396ec5282910b9e8a49c0dd7e",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
        "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
    ],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

############################################################
# Define your own dependencies here using go_repository.
# Else, dependencies declared by rules_go/gazelle will be used.
# The first declaration of an external repository "wins".
############################################################

go_rules_dependencies()

go_register_toolchains(version = "1.18")

gazelle_dependencies()

# rules_docker
# 0.23 breaks something around cc toolchains
http_archive(
    name = "io_bazel_rules_docker",
    sha256 = "59536e6ae64359b716ba9c46c39183403b01eabfbd57578e84398b4829ca499a",
    strip_prefix = "rules_docker-0.22.0",
    urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.22.0/rules_docker-v0.22.0.tar.gz"],
)

load(
    "@io_bazel_rules_docker//repositories:repositories.bzl",
    container_repositories = "repositories",
)

container_repositories()

load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps")

container_deps()

tferi avatar May 14 '22 08:05 tferi

This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!

github-actions[bot] avatar Nov 11 '22 03:11 github-actions[bot]

This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"

github-actions[bot] avatar Dec 12 '22 02:12 github-actions[bot]