protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
65.38k stars 15.46k forks source link

Unable to build Protobuf from source distribution #15615

Closed jaskij closed 2 months ago

jaskij commented 8 months ago

What version of protobuf and what language are you using? Version: 25.2 Language: C++ (?)

What operating system (Linux, Windows, ...) and version?

Arch Linux, up to date

What runtime / compiler are you using (e.g., python version or gcc version)

$ bazel --version
bazel 7.0.1
$ gcc --version
gcc (GCC) 13.2.1 20230801
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

What did you do? Steps to reproduce the behavior:

  1. Go to https://github.com/protocolbuffers/protobuf/releases/tag/v25.2
  2. Download protobuf-25.2.tar.gz
  3. Unpack it
  4. Run bazel build :protobuf

What did you expect to see

A successful build

What did you see instead?

$ bazel build :protobuf
ERROR: no such package '@@com_google_protobuf//': The repository '@@com_google_protobuf' could not be resolved: Repository '@@com_google_protobuf' is not defined
ERROR: /home/jaskij/.cache/bazel/_bazel_jaskij/bb908db786c07cae9b652052a31c83d3/external/bazel_tools/tools/proto/BUILD:25:6: no such package '@@com_google_protobuf//': The repository '@@com_google_protobuf' could not be resolved: Repository '@@com_google_protobuf' is not defined and referenced by '@@bazel_tools//tools/proto:cc_toolchain'
ERROR: Analysis of target '//:protobuf' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.172s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
zhangskz commented 8 months ago

@acozzette Is this a side-effect of the monorepo merge?

jaskij commented 8 months ago

Is this a side-effect of the monorepo merge?

To add more context: it works up until 3.20.3. It seems I didn't push my changes, but I was updating this dockerfile over the weekend, and 3.20.3 worked just fine. 25.2 gave me more trouble than I wanted to deal with at the time. I didn't check version inbetween.

igastru commented 8 months ago

I get this error when I try to install 240131_14h44m35s_screenshot

pdecks commented 7 months ago

Versioning changed with 3.21 per https://protobuf.dev/news/2022-05-06/

The first instance of this new versioning scheme is the new version of the Python API, 4.21.0, which follows the preceding version, 3.20.1. Other language APIs will be released as 3.21.0.

In your Dockerfile, you're currently using the same version number for both C++ and Python:

    PROTOBUF_CPP_FILE=protobuf-cpp-${PROTOBUF_VERSION}.tar.gz \
    PROTOBUF_PY_FILE=protobuf-python-${PROTOBUF_VERSION}.tar.gz \

So you'll have to use ARG PROTOBUF_VERSION=25.2 and then prefix appropriately:

    PROTOBUF_CPP_FILE=protobuf-cpp-3.${PROTOBUF_VERSION}.tar.gz \
    PROTOBUF_PY_FILE=protobuf-python-4.${PROTOBUF_VERSION}.tar.gz \
jaskij commented 7 months ago

@pdecks the error shows up in local builds on my host machine, where I'm not using Docker at all. Just plain download the file and try to build with Bazel.

I am aware of the versioning change. Packaging has also changed, if you look at version 25.2 there is now only one archive with ${PROTOBUF_VERSION}.tar.gz, skipping the major version name. There are no per-language archives. I probably shouldn't have linked that Dockerfile, it's a bit of a red herring here.

pdecks commented 7 months ago

Ah yeah, thanks for clarifying. I did indeed get distracted by the Dockerfile. Confirming I see the same behavior when trying to build 25.3 with bazel 7.0.2 via bazel build :protoc :protobuf.

pdecks commented 7 months ago

This is related https://github.com/bazelbuild/bazel/issues/19973, and I just verified that I was able to successfully build protobuf 25.3 with bazel 6.5.0.

jaskij commented 7 months ago

Thanks for finding that, seems like the issue lies a little deeper. When I get back to the topic, using an older version of Bazel could be a viable workaround.

That said, one of the comments ( https://github.com/bazelbuild/bazel/issues/19973#issuecomment-1787964362 ) in the Bazel issue seems to suggest a workaround for Protobuf?

jaskij commented 6 months ago

@pdecks tested just now with 26.0 and Bazel 7.1.1, don't know what changed, but it seems to build now.

At least bazel build :protoc :protobuf doesn't throw an error. I still have no clue how to get libprotobuf.so, but that's a different issue.

github-actions[bot] commented 3 months ago

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] commented 2 months ago

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.