Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Compatibility issue with bazel 6 #1302

@parthea

Description

@parthea

Steps to reproduce

  1. Install Bazel 6 and confirm the version using bazel --version
partheniou@partheniou-vm-2:~/git$ bazel --version
bazel 6.0.0
  1. Bazel build fails to build java targets
Repository rule http_archive defined at:
 /usr/local/google/home/partheniou/.cache/bazel/_bazel_partheniou/9063cec94a6a99d93035235cd3e5a885/external/bazel_tools/tools/build_defs/repo/http.bzl:372:31: in <toplevel>
ERROR: /usr/local/google/home/partheniou/.cache/bazel/_bazel_partheniou/9063cec94a6a99d93035235cd3e5a885/external/gapic_generator_java/rules_java_gapic/BUILD.bazel:7:8: @gapic_generator_java//rules_java_gapic:gradlew: no such attribute 'extension' in '_real_pkg_tar' rule
ERROR: /usr/local/google/home/partheniou/.cache/bazel/_bazel_partheniou/9063cec94a6a99d93035235cd3e5a885/external/gapic_generator_java/rules_java_gapic/BUILD.bazel:7:8: @gapic_generator_java//rules_java_gapic:gradlew: no such attribute 'files' in '_real_pkg_tar' rule
ERROR: /usr/local/google/home/partheniou/.cache/bazel/_bazel_partheniou/9063cec94a6a99d93035235cd3e5a885/external/gapic_generator_java/rules_java_gapic/BUILD.bazel:7:8: @gapic_generator_java//rules_java_gapic:gradlew: no such attribute 'mode' in '_real_pkg_tar' rule
ERROR: /usr/local/google/home/partheniou/.cache/bazel/_bazel_partheniou/9063cec94a6a99d93035235cd3e5a885/external/gapic_generator_java/rules_java_gapic/BUILD.bazel:7:8: @gapic_generator_java//rules_java_gapic:gradlew: no such attribute 'modes' in '_real_pkg_tar' rule
ERROR: /usr/local/google/home/partheniou/git/googleapis/google/cloud/dataqna/v1alpha/BUILD.bazel:99:31: Target '@gapic_generator_java//rules_java_gapic:gradlew' contains an error and its package is in error and referenced by '//google/cloud/dataqna/v1alpha:google-cloud-dataqna-v1alpha-java'
ERROR: Analysis of target '//google/cloud/dataqna/v1alpha:google-cloud-dataqna-v1alpha-java' failed; build aborted: Analysis failed

If I downgrade to bazel 5.2.0 the targets build successfully. The issue is that rules_gapic_java depends on pkg_tar which was removed in bazel 6.0.0. See packaging section in release notes here. There is a note that says users should migrate to @rules_pkg.

We should change this line from
https://github.com/googleapis/gapic-generator-java/blob/d1a16195937df041f65a52717ddf9dc6ceb09b4f/rules_java_gapic/BUILD.bazel#L1
to

load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")

I tested the above change locally and the build succeeded with bazel 6.0.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions