google-deepmind / code_contests

Apache License 2.0
2.04k stars 200 forks source link

Error Running: Bazel #4

Closed xtt5480446 closed 1 year ago

xtt5480446 commented 2 years ago

I followed the readme file to clone the repo and download the data. When I tried bazel run -c opt :print_names_and_sources /tmp/dm-code_contests/code_contests_train.riegeli*, it ran into the error:

ERROR: /home/ubuntu64/.cache/bazel/_bazel_ubuntu64/0383bdf747a541d9fe51b3d550b07b10/external/com_google_riegeli/riegeli/records/BUILD:79:11: Compiling riegeli/records/record_position.cc failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 31 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox
In file included from external/com_google_riegeli/riegeli/records/record_position.cc:36:0:
external/com_google_riegeli/riegeli/bytes/string_writer.h: In instantiation of 'riegeli::StringWriter<Dest>::StringWriter(Dest&&, riegeli::StringWriterBase::Options) [with Dest = std::basic_string<char>*]':
external/com_google_riegeli/riegeli/records/record_position.cc:73:36:   required from here
external/com_google_riegeli/riegeli/bytes/string_writer.h:291:28: error: no matching function for call to 'riegeli::StringWriterBase::StringWriterBase()'
     : dest_(std::move(dest)) {
                            ^
external/com_google_riegeli/riegeli/bytes/string_writer.h:92:17: note: candidate: riegeli::StringWriterBase::StringWriterBase(riegeli::Closed)
   using Writer::Writer;
                 ^
external/com_google_riegeli/riegeli/bytes/string_writer.h:92:17: note:   candidate expects 1 argument, 0 provided
external/com_google_riegeli/riegeli/bytes/string_writer.h:232:8: note: candidate: riegeli::StringWriterBase::StringWriterBase(riegeli::StringWriterBase&&)
 inline StringWriterBase::StringWriterBase(StringWriterBase&& that) noexcept
        ^
external/com_google_riegeli/riegeli/bytes/string_writer.h:232:8: note:   candidate expects 1 argument, 0 provided
In file included from external/com_google_riegeli/riegeli/records/record_position.cc:35:0:
external/com_google_riegeli/riegeli/bytes/string_reader.h: In instantiation of 'riegeli::StringReader<Src>::StringReader(const Src&) [with Src = absl::lts_20211102::string_view]':
external/com_google_riegeli/riegeli/records/record_position.cc:94:35:   required from here
external/com_google_riegeli/riegeli/bytes/string_reader.h:172:66: error: no matching function for call to 'riegeli::StringReaderBase::StringReaderBase()'
 inline StringReader<Src>::StringReader(const Src& src) : src_(src) {
                                                                  ^
external/com_google_riegeli/riegeli/bytes/string_reader.h:46:17: note: candidate: riegeli::StringReaderBase::StringReaderBase(riegeli::Closed)
   using Reader::Reader;
                 ^
external/com_google_riegeli/riegeli/bytes/string_reader.h:46:17: note:   candidate expects 1 argument, 0 provided
external/com_google_riegeli/riegeli/bytes/string_reader.h:157:8: note: candidate: riegeli::StringReaderBase::StringReaderBase(riegeli::StringReaderBase&&)
 inline StringReaderBase::StringReaderBase(StringReaderBase&& that) noexcept
        ^
external/com_google_riegeli/riegeli/bytes/string_reader.h:157:8: note:   candidate expects 1 argument, 0 provided
Target //:print_names_and_sources failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.878s, Critical Path: 1.50s
INFO: 5 processes: 3 internal, 2 linux-sandbox.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

i install bazel using apt install sudo apt update && sudo apt install bazel python 2.7 && python 3.5 ubuntu 16.04 (vmware virtual machine)

jtkeeling commented 2 years ago

Thanks for reporting your issue. I notice you're on Ubuntu 16.04. I don't know what version of GCC you're using, but I believe the latest version provided with that release of Ubuntu is GCC-5.4, which was released in June 2016. This might be too old to compile the riegeli dependency.

Could you double check your GCC version with gcc --version and try compiling with a more recent version of GCC or Clang? You could do this either by installing a new version in your current VM, or by using a more recent version of Ubuntu.

ayush1801 commented 2 years ago

@jtkeeling I am also facing a similar issue:

$ ~/Desktop/CodeGen/bazel run -c opt :print_names_and_sources ~/Desktop/CodeGen/dm-code_contests/code_contests_test.riegeli
Starting local Bazel server and connecting to it...
Loading:
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
DEBUG: Rule 'com_github_grpc_grpc' indicated that a canonical reproducible form can be obtained by modifying arguments commit = "96b73272eadc01afb5fb45b92b408c47e4387274", shallow_since = "1624063996 -0700" and dropping ["tag"]
DEBUG: Repository com_github_grpc_grpc instantiated at:
  C:/users/t-agrawala/desktop/codegen/code_contests/WORKSPACE:4:15: in <toplevel>
Repository rule git_repository defined at:
  C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
Analyzing: target //:print_names_and_sources (1 packages loaded, 0 targets configured)
Analyzing: target //:print_names_and_sources (32 packages loaded, 117 targets configured)
Analyzing: target //:print_names_and_sources (38 packages loaded, 177 targets configured)
Analyzing: target //:print_names_and_sources (38 packages loaded, 177 targets configured)
DEBUG: Rule 'com_google_protobuf' indicated that a canonical reproducible form can be obtained by modifying arguments commit = "cc7b1b53234cd7a8f50d90ac3933b240dcf4cd97", shallow_since = "1641866895 -0800" and dropping ["tag"]
DEBUG: Repository com_google_protobuf instantiated at:
  C:/users/t-agrawala/desktop/codegen/code_contests/WORKSPACE:22:15: in <toplevel>
Repository rule git_repository defined at:
  C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
Analyzing: target //:print_names_and_sources (38 packages loaded, 177 targets configured)
DEBUG: Rule 'rules_python' indicated that a canonical reproducible form can be obtained by modifying arguments commit = "76ef44fdb8aaa8d5c607721ffe1b1cbf1e8f08dd", shallow_since = "1635214215 -0700" and dropping ["tag"]
DEBUG: Repository rules_python instantiated at:
  C:/users/t-agrawala/desktop/codegen/code_contests/WORKSPACE:14:15: in <toplevel>
Repository rule git_repository defined at:
  C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
INFO: Repository local_config_python instantiated at:
  C:/users/t-agrawala/desktop/codegen/code_contests/WORKSPACE:12:10: in <toplevel>
  C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/bazel/grpc_deps.bzl:414:21: in grpc_deps
  C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/bazel/grpc_python_deps.bzl:43:21: in grpc_python_deps
Repository rule python_configure defined at:
  C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/third_party/py/python_configure.bzl:365:35: in <toplevel>
ERROR: An error occurred during the fetch of repository 'local_config_python':
   Traceback (most recent call last):
        File "C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/third_party/py/python_configure.bzl", line 347, column 35, in _python_autoconf_impl
                _create_single_version_package(
        File "C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/third_party/py/python_configure.bzl", line 316, column 42, in _create_single_version_package
                python_include = _normalize_path(python_include)
Error: local variable 'python_include' is referenced before assignment.
ERROR: C:/users/t-agrawala/desktop/codegen/code_contests/WORKSPACE:12:10: fetching python_configure rule //external:local_config_python: Traceback (most recent call last):
        File "C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/third_party/py/python_configure.bzl", line 347, column 35, in _python_autoconf_impl
                _create_single_version_package(
        File "C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/third_party/py/python_configure.bzl", line 316, column 42, in _create_single_version_package
                python_include = _normalize_path(python_include)
Error: local variable 'python_include' is referenced before assignment.
ERROR: C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_google_riegeli/python/riegeli/records/BUILD:54:13: @com_google_riegeli//python/riegeli/records:record_position_cc depends on @local_config_python//:python_headers in repository @local_config_python which failed to fetch. no such package '@local_config_python//': local variable 'python_include' is referenced before assignment.
ERROR: Analysis of target '//:print_names_and_sources' failed; build aborted:
INFO: Elapsed time: 28.900s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (45 packages loaded, 186 targets configured)
ERROR: Build failed. Not running target
FAILED: Build did NOT complete successfully (45 packages loaded, 186 targets configured)

It would be really helpful if you could give me some insights about how to proceed from here.

jtkeeling commented 2 years ago

Hi ayush1801.

This is a distinct issue. You might want to raise a new issue.

But looking at https://github.com/grpc/grpc/blob/master/third_party/py/python_configure.bzl#L313, the error is that python_include is not set.

From reading the source code here, it looks like this will happen on Windows machines that do not have Python2 installed. Whilst Python2 is not actually a requirement of code_contests, this is happening in our indirect GRPC dependency over which we don't have much control.

I would recommend installing Python2 and seeing if this fixes your problem.

ayush1801 commented 2 years ago

Hi @jtkeeling! Thanks for the suggestion, however similar error is coming after installing python 2.7.

$ ~/Desktop/CodeGen/bazel run -c opt :print_names_and_sources ~/Desktop/CodeGen/dm-code_contests/code_contests_test.riegeli
Starting local Bazel server and connecting to it...
Loading:
Loading: 0 packages loaded
Analyzing: target //:print_names_and_sources (1 packages loaded, 0 targets configured)
INFO: Repository local_config_python instantiated at:
  C:/users/t-agrawala/desktop/codegen/code_contests/WORKSPACE:12:10: in <toplevel>
  C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/bazel/grpc_deps.bzl:414:21: in grpc_deps
  C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/bazel/grpc_python_deps.bzl:43:21: in grpc_python_deps
Repository rule python_configure defined at:
  C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/third_party/py/python_configure.bzl:365:35: in <toplevel>
ERROR: An error occurred during the fetch of repository 'local_config_python':
   Traceback (most recent call last):
        File "C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/third_party/py/python_configure.bzl", line 347, column 35, in _python_autoconf_impl
                _create_single_version_package(
        File "C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/third_party/py/python_configure.bzl", line 316, column 42, in _create_single_version_package
                python_include = _normalize_path(python_include)
Error: local variable 'python_include' is referenced before assignment.
ERROR: C:/users/t-agrawala/desktop/codegen/code_contests/WORKSPACE:12:10: fetching python_configure rule //external:local_config_python: Traceback (most recent call last):
        File "C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/third_party/py/python_configure.bzl", line 347, column 35, in _python_autoconf_impl
                _create_single_version_package(
        File "C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_github_grpc_grpc/third_party/py/python_configure.bzl", line 316, column 42, in _create_single_version_package
                python_include = _normalize_path(python_include)
Error: local variable 'python_include' is referenced before assignment.
ERROR: C:/users/t-agrawala/_bazel_t-agrawala/2bxpaxyo/external/com_google_riegeli/python/riegeli/records/BUILD:54:13: @com_google_riegeli//python/riegeli/records:record_position_cc depends on @local_config_python//:python_headers in repository @local_config_python which failed to fetch. no such package '@local_config_python//': local variable 'python_include' is referenced before assignment.
ERROR: Analysis of target '//:print_names_and_sources' failed; build aborted:
INFO: Elapsed time: 7.217s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (50 packages loaded, 182 targets configured)
ERROR: Build failed. Not running target

Can you suggest any workaround for this issue or maybe another way to read the RIEGELI files?

davidhchoi commented 2 years ago

Sorry for the late reply. Can you try the instructions that worked for someone else here: https://github.com/deepmind/code_contests/issues/9#issuecomment-1064091580 ?