Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation with bazel 6.0.0 #221

Open
w4-jihunlorenzopark opened this issue Dec 20, 2022 · 4 comments
Open

Installation with bazel 6.0.0 #221

w4-jihunlorenzopark opened this issue Dec 20, 2022 · 4 comments

Comments

@w4-jihunlorenzopark
Copy link

I was using copybara by building binary with bazel and have used bazelisk for a version management.
However, from yesterday, as releasing of bazel 6.0.0, the bazelisk on my local starts to use 6.0.0 and fails when building copybara binary.

bazel build //java/com/google/copybara:copybara_deploy.jar
2022/12/20 16:35:49 Downloading https://releases.bazel.build/6.0.0/release/bazel-6.0.0-darwin-x86_64...
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
ERROR: /Users/user/copybara/third_party/BUILD:159:13: in java_library rule //third_party:starlark: target '@io_bazel//src/main/java/net/starlark/java/annot:annot' is not visible from target '//third_party:starlark'. Check the visibility declaration of the former target if you think the dependency is legitimate
ERROR: /Users/user/copybara/third_party/BUILD:159:13: in java_library rule //third_party:starlark: target '@io_bazel//src/main/java/net/starlark/java/eval:eval' is not visible from target '//third_party:starlark'. Check the visibility declaration of the former target if you think the dependency is legitimate
ERROR: /Users/user/copybara/third_party/BUILD:159:13: in java_library rule //third_party:starlark: target '@io_bazel//src/main/java/net/starlark/java/syntax:syntax' is not visible from target '//third_party:starlark'. Check the visibility declaration of the former target if you think the dependency is legitimate
ERROR: /Users/user/copybara/third_party/BUILD:159:13: Analysis of target '//third_party:starlark' failed
ERROR: Analysis of target '//java/com/google/copybara:copybara_deploy.jar' failed; build aborted: 
INFO: Elapsed time: 50.543s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (92 packages loaded, 1625 targets configured)
    Fetching repository @maven; Resolving and fetching the transitive closure of 26 artifact(s).. 19s

It seems one of the thirdparty is not working well with new release of bazel.
Current workaround would be using USE_BAZEL_VERSION=5.x.x bazel build //java/com/google/copybara:copybara_deploy.jar
How about adding .bazelversion in this repo and specify the recommended version in the file for bazel users?

https://github.com/bazelbuild/bazelisk#how-does-bazelisk-know-which-bazel-version-to-run

@mikelalcon
Copy link
Collaborator

I think .bazelversion makes sense.

I reproduced myself on Mac too. We also need to figure out why it is not working with Bazel 6.

@mikelalcon
Copy link
Collaborator

Actually I spoke too soon. We have an issue with our CI if we set bazel to a fixed version.

@restingbull
Copy link

restingbull commented Jan 5, 2023

Needs to have the bazel version bumped past: bazelbuild/bazel@01314ce

Mitigation for folks stuck here:


load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

copybara_commit="609fbe374a96ede32f8db71ad112d2c17d0951ee"
copybara_sha256="5dff2739c16fe61176e10d2dc71f6211fc81a52f0ff1642d0bef5e2f57c643c7"
http_archive(
    name = "com_github_google_copybara",
    sha256 = copybara_sha256,
    strip_prefix = "copybara-%s" % copybara_commit,
    urls = [
        "https://github.com/google/copybara/archive/%s.tar.gz" % copybara_commit,
    ],
)

# workaround for https://github.com/google/copybara/issues/221
load("@com_github_google_copybara//third_party:bazel.bzl", "bazel_version", "bazel_sha256")
http_archive(
  name = "io_bazel",
  sha256 = bazel_sha256,
  strip_prefix = "bazel-%s" % bazel_version,
  url = "https://github.com/bazelbuild/bazel/archive/%s.zip" %bazel_version,
  patch_cmds = ["""sed -i.bak 's/packages = \\["\\/\\/..."]/packages = ["public"]/' src/main/java/net/starlark/java/BUILD"""]
)

load("@com_github_google_copybara//:repositories.bzl", "copybara_repositories")

copybara_repositories()

load("@com_github_google_copybara//:repositories.maven.bzl", "copybara_maven_repositories")

copybara_maven_repositories()

load("@com_github_google_copybara//:repositories.go.bzl", "copybara_go_repositories")

copybara_go_repositories()

Note -- using head failed for an unrelated reason:

        ^
external/com_github_google_copybara/java/com/google/copybara/onboard/core/AskInputProvider.java:117: error: cannot find symbol
                    var unused = input.convert(s, resolver);
                    ^
  symbol:   class var
  location: class Mode
external/com_github_google_copybara/java/com/google/copybara/onboard/core/InputProviderResolverImpl.java:60: error: cannot find symbol
      var unused = generator.consumes();
      ^
  symbol:   class var
  location: class InputProviderResolverImpl

@Vertexwahn
Copy link

I have the same issue with Bazel 6.0.0 on Ubuntu 22.04:

bazel build //java/com/google/copybara gives me

Starting local Bazel server and connecting to it...
INFO: Invocation ID: 7cd9105a-a9ac-43da-8ffb-a865ab877cfc
ERROR: /home/vertexwahn/dev/Piper/third_party/copybara/third_party/BUILD:166:13: in java_library rule //third_party:starlark: target '@io_bazel//src/main/java/net/starlark/java/annot:annot' is not visible from target '//third_party:starlark'. Check the visibility declaration of the former target if you think the dependency is legitimate
ERROR: /home/vertexwahn/dev/Piper/third_party/copybara/third_party/BUILD:166:13: in java_library rule //third_party:starlark: target '@io_bazel//src/main/java/net/starlark/java/eval:eval' is not visible from target '//third_party:starlark'. Check the visibility declaration of the former target if you think the dependency is legitimate
ERROR: /home/vertexwahn/dev/Piper/third_party/copybara/third_party/BUILD:166:13: in java_library rule //third_party:starlark: target '@io_bazel//src/main/java/net/starlark/java/lib/json:json' is not visible from target '//third_party:starlark'. Check the visibility declaration of the former target if you think the dependency is legitimate
ERROR: /home/vertexwahn/dev/Piper/third_party/copybara/third_party/BUILD:166:13: in java_library rule //third_party:starlark: target '@io_bazel//src/main/java/net/starlark/java/syntax:syntax' is not visible from target '//third_party:starlark'. Check the visibility declaration of the former target if you think the dependency is legitimate
ERROR: /home/vertexwahn/dev/Piper/third_party/copybara/third_party/BUILD:166:13: Analysis of target '//third_party:starlark' failed
ERROR: Analysis of target '//java/com/google/copybara:copybara' failed; build aborted: 
INFO: Elapsed time: 4.945s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (96 packages loaded, 1441 targets configured)

g-ortuno added a commit to g-ortuno/copybara that referenced this issue May 11, 2023
Suggests adding `--java_language_version` and `--tool_java_language_version` to .bazelrc.

Context: I just spent three days trying to build copybara in an external workspace and kept getting the following error (which is also mentioned in google#221 ):
```
external/com_github_google_copybara/java/com/google/copybara/onboard/core/AskInputProvider.java:117: error: cannot find symbol
                    var unused = input.convert(s, resolver);
                    ^
  symbol:   class var
  location: class Mode
external/com_github_google_copybara/java/com/google/copybara/onboard/core/InputProviderResolverImpl.java:60: error: cannot find symbol
      var unused = generator.consumes();
      ^
  symbol:   class var
  location: class InputProviderResolverImpl
```

I realized that I needed to update my .bazelrc only after combing through the changes trying to find a clue as to how to fix the issue.

I'm pretty new to bazel external repositories, having mostly worked with blaze and Chromium's GN, but I thought mentioning this in the docs could help other developers starting with bazel.

If the fix is too obvious, feel free to ignore :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants