-
-
Notifications
You must be signed in to change notification settings - Fork 723
Description
When using the Bazel gopackagesdriver to analyze a rules_go project it's
possible to run into missing packages errors that look like
/home/user/go/bazel-pkgdrv/execroot/__main__/bazel-out/
k8-fastbuild/example.go:8:7: could not import example.org/mock (missing package: "@//src/example.org/mock:go_default_library")
The root cause is that the gopackagesdriver aspect only traverses
target's deps field to populate the package information in the
driver registry. In cases where a target depends on another target
that is not declared in the "deps" field this packages will be missing
from the gopackagesdriver response.
An example of this edge case is on-the-fly generated go code produced
by a bazel rule where the bazel rule provides a static dependency in
the rule implementation instead of relying soley on the deps attribute.
In this situation, this package is still required for the package
analysis to complete but it is missing from the gopackagesdriver
response.
A solution is to provide a additional labels field that the gopackages driver will
always add to the packages registry.