rules-proto-grpc / rules_proto_grpc

Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets
https://rules-proto-grpc.com
Apache License 2.0
249 stars 156 forks source link

Build of examples fails: no such package '@@rules_proto_grpc~override//go': BUILD file not found in directory 'go' #300

Closed mgingios closed 8 months ago

mgingios commented 8 months ago

Issue Description

I downloaded the master branch from this repo so I could build the examples. The build failed.
bazel query "@rules_proto_grpc//go:*" Displayed the same error message.

Log Output

bazel query "@rules_proto_grpc//go:*"
(18:22:50) INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=270
(18:22:50) INFO: Reading rc options for 'query' from /Users/mike/Go/src/github.com/ingios/ingiosapis/.bazelrc:
  Inherited 'common' options: --announce_rc --show_timestamps --enable_bzlmod
(18:22:50) INFO: Reading rc options for 'query' from /Users/mike/Go/src/github.com/ingios/ingiosapis/.bazelrc:
  'query' options: --noexperimental_check_external_repository_files
(18:22:50) INFO: Current date is 2023-12-14
(18:22:50) ERROR: no such package '@@rules_proto_grpc~override//go': BUILD file not found in directory 'go' of external repository @@rules_proto_grpc~override. Add a BUILD file to a directory to mark it as a package.
?7 src % bazel query "@rules_proto_grpc//go:*"
Attempt to build:
(18:32:17) ERROR: /Users/mike/Go/src/github.com/ingios/ingiosapis/modules/core/BUILD.bazel:3:12: no such package 'internal': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - /Users/mike/Go/src/github.com/ingios/ingiosapis/internal and referenced by '//modules/core:defs'

rules_proto_grpc Version

bazel_dep(name = "rules_proto_grpc", version = "0.0.0.rpg.version.placeholder") local_path_override( module_name = "rules_proto_grpc", path = "modules/core", )

Bazel Version

7.0.0

OS

macos sonoma

Link to Demo Repo

No response

WORKSPACE Content

WORKSPACE file is empty.

MODULE.bazel
module(
    name = "insapis",
    version = "5.5.0-rc1",
    compatibility_level = 1,
)

bazel_dep(
    name = "buildifier_prebuilt",
    version = "6.3.3",
    dev_dependency = True,
)

bazel_dep(
    name = "gazelle",
    version = "0.34.0",
    repo_name = "bazel_gazelle",
)
bazel_dep(
    name = "platforms",
    version = "0.0.8",
)
bazel_dep(
    name = "rules_go",
    version = "0.43.0",
    repo_name = "io_bazel_rules_go",
)
#bazel_dep(
#    name = "grpc",
#    version = "1.48.1",
#)
#bazel_dep(
#    name = "protobuf",
#    version = "21.7",
#)
# gRPC-Gateway
bazel_dep(name = "rules_proto_grpc_grpc_gateway", version = "0.0.0.rpg.version.placeholder")
local_path_override(
    module_name = "rules_proto_grpc_grpc_gateway",
    path = "modules/grpc_gateway",
)

# Go
bazel_dep(name = "rules_proto_grpc_go", version = "0.0.0.rpg.version.placeholder")
local_path_override(
    module_name = "rules_proto_grpc_go",
    path = "modules/go",
)

bazel_dep(name = "rules_proto_grpc", version = "0.0.0.rpg.version.placeholder")
local_path_override(
    module_name = "rules_proto_grpc",
    path = "modules/core",
)

go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")

# Download an SDK for the host OS & architecture.
go_sdk.download(version = "1.21.3")

# Register the go.mod file with the go_deps extension.
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")

# All *direct* Go dependencies of the module have to be listed explicitly.
use_repo(
    go_deps,
)

# Register the Go SDK installed on the host.
go_sdk.host()

BUILD Content

load("@bazel_gazelle//:def.bzl", "gazelle")
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
#load("@rules_proto_grpc//go:defs.bzl", "go_grpc_compile", "go_grpc_library")
#load("@rules_proto_grpc//grpc-gateway:defs.bzl", "gateway_grpc_compile")

# gazelle:prefix github.com/ingios/falcon/v5
# gazelle:exclude bazel-*
# gazelle:exclude binding
# gazelle:exclude deployment
# gazelle:exclude dist
# gazelle:exclude security
# gazelle:exclude vendor
gazelle(name = "gazelle")

gazelle(
    name = "gazelle-update-repos",
    args = [
        "-from_file=go.mod",
        "-to_macro=deps.bzl%go_dependencies",
        "-prune",
        "-build_file_proto_mode=disable_global",
    ],
    command = "update-repos",
)

# make sure that others can import either using the import or go_default_library naming conventions
# gazelle:go_naming_convention import_alias

buildifier(
    name = "buildifier.check",
    exclude_patterns = [
        "./bazel-*",
        "./git/*",
        "./vendor/*",
    ],
    lint_mode = "warn",
    lint_warnings = ["all"],
    mode = "check",
    verbose = True,
)

Proto Content

N/A.  This error is before any attempts to compile the protos.

Any Other Content

No response

aaliddell commented 8 months ago

The docs aren't completed yet for the alpha version using bzlmod, but you need to load the go rules from the language specific module now (i.e @rules_proto_grpc_go), like so:

load("@rules_proto_grpc_go//:defs.bzl", "go_grpc_library")