bazel-gazelle icon indicating copy to clipboard operation
bazel-gazelle copied to clipboard

gazelle not properly generating build files for `github.com/census-instrumentation/opencensus-proto/`

Open richardstephens opened this issue 2 years ago • 1 comments

What version of gazelle are you using?

v0.29.0

What version of rules_go are you using?

v0.38.1

What version of Bazel are you using?

v6.0.0

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

Darwin arm64 Linux amd64

What did you do?

Updated a fairly large go project from 1.16.2 to 1.19.5, and bumped many very out of date dependencies to their latest or close to. Most of the problems where resolved by careful selection of compatible versions, but one appears to be a bug in gazelle. For now I have forked the library, run gazelle on my fork, and checked in the build files, which works.

I have built and published a minimal reproduction case here.

What did you expect to see?

The build should complete successfully, as it does when invoking go directly.

What did you see instead?

bazel build --verbose_failures -s --sandbox_debug //:project
INFO: Analyzed target //:project (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
SUBCOMMAND: # @com_github_census_instrumentation_opencensus_proto//gen-go/trace/v1:trace [action 'GoCompilePkg external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1/trace.a', configuration: 602a7de8f53d7519ab643e503734b06f4b806876484cf03fcd3bf29b68cb068e, execution platform: @local_config_platform//:host]
(cd /private/var/tmp/_bazel_richard.stephens/34627ec4042a4eb707f69e3728999fc7/execroot/__main__ && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=13.1 \
    CGO_ENABLED=1 \
    GOARCH=arm64 \
    GOOS=darwin \
    GOPATH='' \
    GOROOT=external/go_sdk \
    GOROOT_FINAL=GOROOT \
    PATH=external/local_config_cc:/bin:/usr/bin \
    XCODE_VERSION_OVERRIDE=14.2.0.14C18 \
    ZERO_AR_DATE=1 \
  bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/go_sdk/builder_reset/builder compilepkg -sdk external/go_sdk -installsuffix darwin_arm64 -src external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1/trace.pb.go -src external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1/trace_config.pb.go -embedroot '' -embedroot bazel-out/darwin_arm64-fastbuild/bin -embedlookupdir external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1 -arc 'google.golang.org/protobuf/reflect/protoreflect=google.golang.org/protobuf/reflect/protoreflect=bazel-out/darwin_arm64-fastbuild/bin/external/org_golang_google_protobuf/reflect/protoreflect/protoreflect.x' -arc 'google.golang.org/protobuf/runtime/protoimpl=google.golang.org/protobuf/runtime/protoimpl=bazel-out/darwin_arm64-fastbuild/bin/external/org_golang_google_protobuf/runtime/protoimpl/protoimpl.x' -arc 'google.golang.org/protobuf/types/known/timestamppb=google.golang.org/protobuf/types/known/timestamppb=bazel-out/darwin_arm64-fastbuild/bin/external/org_golang_google_protobuf/types/known/timestamppb/timestamppb.x' -arc 'google.golang.org/protobuf/types/known/wrapperspb=google.golang.org/protobuf/types/known/wrapperspb=bazel-out/darwin_arm64-fastbuild/bin/external/org_golang_google_protobuf/types/known/wrapperspb/wrapperspb.x' -importpath github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1 -p github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1 -package_list bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/go_sdk/packages.txt -o bazel-out/darwin_arm64-fastbuild/bin/external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1/trace.a -x bazel-out/darwin_arm64-fastbuild/bin/external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1/trace.x -gcflags '' -asmflags '')
# Configuration: 602a7de8f53d7519ab643e503734b06f4b806876484cf03fcd3bf29b68cb068e
# Execution platform: @local_config_platform//:host
ERROR: /private/var/tmp/_bazel_richard.stephens/34627ec4042a4eb707f69e3728999fc7/external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1/BUILD.bazel:3:11: GoCompilePkg external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1/trace.a failed: (Exit 1): sandbox-exec failed: error executing command 
  (cd /private/var/tmp/_bazel_richard.stephens/34627ec4042a4eb707f69e3728999fc7/sandbox/darwin-sandbox/133/execroot/__main__ && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=13.1 \
    CGO_ENABLED=1 \
    DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \
    GOARCH=arm64 \
    GOOS=darwin \
    GOPATH='' \
    GOROOT=external/go_sdk \
    GOROOT_FINAL=GOROOT \
    PATH=external/local_config_cc:/bin:/usr/bin \
    SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk \
    TMPDIR=/var/folders/08/3v1d6zh922d5vzb4f8yw5f5c0000gp/T/ \
    XCODE_VERSION_OVERRIDE=14.2.0.14C18 \
    ZERO_AR_DATE=1 \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_richard.stephens/34627ec4042a4eb707f69e3728999fc7/sandbox/darwin-sandbox/133/sandbox.sb /var/tmp/_bazel_richard.stephens/install/730b09b9d9f2bfd30b4c0a074ba23835/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_richard.stephens/34627ec4042a4eb707f69e3728999fc7/sandbox/darwin-sandbox/133/stats.out' bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/go_sdk/builder_reset/builder compilepkg -sdk external/go_sdk -installsuffix darwin_arm64 -src external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1/trace.pb.go -src external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1/trace_config.pb.go -embedroot '' -embedroot bazel-out/darwin_arm64-fastbuild/bin -embedlookupdir external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1 -arc 'google.golang.org/protobuf/reflect/protoreflect=google.golang.org/protobuf/reflect/protoreflect=bazel-out/darwin_arm64-fastbuild/bin/external/org_golang_google_protobuf/reflect/protoreflect/protoreflect.x' -arc 'google.golang.org/protobuf/runtime/protoimpl=google.golang.org/protobuf/runtime/protoimpl=bazel-out/darwin_arm64-fastbuild/bin/external/org_golang_google_protobuf/runtime/protoimpl/protoimpl.x' -arc 'google.golang.org/protobuf/types/known/timestamppb=google.golang.org/protobuf/types/known/timestamppb=bazel-out/darwin_arm64-fastbuild/bin/external/org_golang_google_protobuf/types/known/timestamppb/timestamppb.x' -arc 'google.golang.org/protobuf/types/known/wrapperspb=google.golang.org/protobuf/types/known/wrapperspb=bazel-out/darwin_arm64-fastbuild/bin/external/org_golang_google_protobuf/types/known/wrapperspb/wrapperspb.x' -importpath github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1 -p github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1 -package_list bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/go_sdk/packages.txt -o bazel-out/darwin_arm64-fastbuild/bin/external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1/trace.a -x bazel-out/darwin_arm64-fastbuild/bin/external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1/trace.x -gcflags '' -asmflags '')
compilepkg: missing strict dependencies:
	/private/var/tmp/_bazel_richard.stephens/34627ec4042a4eb707f69e3728999fc7/sandbox/darwin-sandbox/133/execroot/__main__/external/com_github_census_instrumentation_opencensus_proto/gen-go/trace/v1/trace.pb.go: import of "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1"
No dependencies were provided.
Check that imports in Go sources match importpath attributes in deps.
Target //:project failed to build
INFO: Elapsed time: 0.274s, Critical Path: 0.05s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully

Analysis

When gazelle generates build files for the github.com/census-instrumentation/opencensus-proto dep, it does not include a dep for github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1 in its build file for github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1.

richardstephens avatar Feb 15 '23 16:02 richardstephens

This description holds true for me.

TL;DR: Take a look at build_extra_args in the below go_repository rule

    go_repository(
        name = "com_github_census_instrumentation_opencensus_proto",
        build_extra_args = ["-exclude=src"],
        importpath = "github.com/census-instrumentation/opencensus-proto",
        sum = "h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g=",
        version = "v0.4.1",
    )

Geethree avatar May 09 '23 19:05 Geethree