protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Unable to build Protobuf from source distribution

Open jaskij opened this issue 1 year ago • 10 comments

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

jaskij avatar Jan 28 '24 05:01 jaskij

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

zhangskz avatar Jan 30 '24 17:01 zhangskz

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.

jaskij avatar Jan 30 '24 17:01 jaskij

I get this error when I try to install 240131_14h44m35s_screenshot

igastru avatar Jan 31 '24 20:01 igastru

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 \

pdecks avatar Feb 10 '24 01:02 pdecks

@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.

jaskij avatar Feb 10 '24 16:02 jaskij

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 avatar Mar 05 '24 04:03 pdecks

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.

pdecks avatar Mar 05 '24 05:03 pdecks

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 avatar Mar 05 '24 12:03 jaskij

@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.

jaskij avatar Mar 27 '24 20:03 jaskij

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] avatar Jun 26 '24 10:06 github-actions[bot]

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.

github-actions[bot] avatar Jul 10 '24 10:07 github-actions[bot]