Issue building 2.1.50beta3

Dunno if this should go into a dev thread, but with the recent changes to how bazel now called via ./tools/bazel, the build instantly breaks for me:

INFO: Repository python instantiated at:
  /tmp/anki-git/WORKSPACE:14:11: in <toplevel>
  /tmp/anki-git/defs.bzl:27:23: in setup_deps
Repository rule setup_local_python defined at:
  /tmp/anki-git/python/python.bzl:100:37: in <toplevel>
ERROR: An error occurred during the fetch of repository 'python':
   Traceback (most recent call last):
	File "/tmp/anki-git/python/python.bzl", line 60, column 33, in _impl
		platform = _get_platform(rctx)
	File "/tmp/anki-git/python/python.bzl", line 42, column 26, in _get_platform
		arch = _unix_arch(rctx)
	File "/tmp/anki-git/python/python.bzl", line 29, column 13, in _unix_arch
		fail("invoking arch failed", result.stderr)
Error in fail: invoking arch failed src/main/tools/process-wrapper-legacy.cc:80: "execvp(uname, ...)": No such file or directory
ERROR: /tmp/anki-git/WORKSPACE:14:11: fetching setup_local_python rule //external:python: Traceback (most recent call last):
	File "/tmp/anki-git/python/python.bzl", line 60, column 33, in _impl
		platform = _get_platform(rctx)
	File "/tmp/anki-git/python/python.bzl", line 42, column 26, in _get_platform
		arch = _unix_arch(rctx)
	File "/tmp/anki-git/python/python.bzl", line 29, column 13, in _unix_arch
		fail("invoking arch failed", result.stderr)
Error in fail: invoking arch failed src/main/tools/process-wrapper-legacy.cc:80: "execvp(uname, ...)": No such file or directory
ERROR: error loading package '': at /tmp/anki-git/late_deps.bzl:3:6: Encountered error while reading extension file 'requirements.bzl': no such package '@py_deps//': no such package '@python//': invoking arch failed src/main/tools/process-wrapper-legacy.cc:80: "execvp(uname, ...)": No such file or directory

This with bazel 5.0.0 on Linux x64, with ~/.config/bazel* and traces of the previous builds in Anki’s git folder deleted (IOW, git status is clean).

Please add an ‘echo $PATH’ line before and after the ‘export PATH’ line in tools/bazel - it seems like the folder that contains uname is accidentally being stripped from the path.

before yields

/usr/lib/ccache/bin:/usr/lib/colorgcc/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/android-sdk/emulator:/opt/android-sdk/cmdline-tools/latest/bin:/opt/android-sdk/platform-tools:/opt/dotnet/tools:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

after yields

/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

Does replacing the export PATH line with these two lines fix it?

toolsPath=$(dirname $0)
export PATH=$(echo "$PATH" | sed "s@${toolsPath}:@@")

Yields a different error, unfortunately:

  /tmp/anki-git/WORKSPACE:14:11: in <toplevel>
  /tmp/anki-git/defs.bzl:35:14: in setup_deps
  /home/me/.cache/bazel/_bazel_me/2db475aa49d0f71ae9f0fe14cd4f9406/external/rules_python/python/pip.bzl:184:19: in pip_parse
Repository rule pip_repository defined at:
  /home/me/.cache/bazel/_bazel_me/2db475aa49d0f71ae9f0fe14cd4f9406/external/rules_python/python/pip_install/pip_repository.bzl:276:33: in <toplevel>
ERROR: An error occurred during the fetch of repository 'py_deps':
   Traceback (most recent call last):
	File "/home/me/.cache/bazel/_bazel_me/2db475aa49d0f71ae9f0fe14cd4f9406/external/rules_python/python/pip_install/pip_repository.bzl", line 171, column 13, in _pip_repository_impl
		fail("rules_python failed: %s (%s)" % (result.stdout, result.stderr))
Error in fail: rules_python failed:  (/home/me/.cache/bazel/_bazel_me/2db475aa49d0f71ae9f0fe14cd4f9406/external/python/python: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory
)
ERROR: /tmp/anki-git/WORKSPACE:14:11: fetching pip_repository rule //external:py_deps: Traceback (most recent call last):
	File "/home/me/.cache/bazel/_bazel_me/2db475aa49d0f71ae9f0fe14cd4f9406/external/rules_python/python/pip_install/pip_repository.bzl", line 171, column 13, in _pip_repository_impl
		fail("rules_python failed: %s (%s)" % (result.stdout, result.stderr))
Error in fail: rules_python failed:  (/home/me/.cache/bazel/_bazel_me/2db475aa49d0f71ae9f0fe14cd4f9406/external/python/python: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory
)
ERROR: no such package '@py_deps//': rules_python failed:  (/home/me/.cache/bazel/_bazel_me/2db475aa49d0f71ae9f0fe14cd4f9406/external/python/python: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory
)

Same as when I now try to run bazel build directly.

… though in fact, if I try to run ./tools/bazel directly / outside Arch makepkg’s chroot, it does / outputs nothing at all

What distro are you using? If you’re on Fedora, maybe you need to install libxcrypt-compat.

It’s Arch. Is python bundled now or did something chance in the way it’s invoked? Building Anki from git never had this issue.

It was changed in Oct, and it allows the build to work even if the user’s distro uses an older or newer Python version. Python links to libcrypt by default. Libcrypt was traditionally distributed with glibc, but they decided to split it off, and this has broken a bunch of stuff that assume it will be available. Presumably arch has some compat package you can install for now, and I will see if I can exclude it from the binary when I have a chance.

2 Likes

Thank you for that hint: Arch recently updated its glibc after months of maintainer troubles. Looking through the changes, libcrypt.so.1 was removed. So the python error is indeed not directly related.

Ah, the maintainer of anki-git AUR buildscript added a workaround of their own:

echo "build --action_env=PYO3_PYTHON=/usr/bin/python3" > "$srcdir/$pkgname/user.bazelrc"

(Also, there was a typo in my previous comment.)

Yes, that approach is documented in docs/linux.md. It uses the system Python, which may or may not work depending on the distro.