Bazel build ERROR on ubuntu
I am using Linux Ubuntu 22.04.3 LTS (WSL 2) on a windows 11 machine and I have python 3.10, numpy 1.26.3 and bazel 7.0.0 installed. I modified the WORKSPACE script according to my path to python and numpy, which are respectively: /usr/include/python3.10 /usr/local/lib/python3.10/dist-packages/numpy/core/
However, when I go in qcc/src/lib and try to build using bazel build all I got this error:
ERROR: /home/username/qcc/WORKSPACE:1:21: //external:third_party_python: invalid label '/home/username/qcc/python.BUILD' in attribute 'build_file' in 'new_local_repository' rule: invalid target name '/home/username/qcc/python.BUILD': target names may not start with '/' ERROR: /home/username/qcc/WORKSPACE:8:21: //external:third_party_numpy: invalid label '/home/username/qcc/numpy.BUILD' in attribute 'build_file' in 'new_local_repository' rule: invalid target name '/home/username/qcc/numpy.BUILD': target names may not start with '/' ERROR: Error computing the main repository mapping: Encountered error while reading extension file 'toolchains/jdk_build_file.bzl': no such package '@@rules_java_builtin//toolchains': error loading package 'external': Could not load //external package
SOLUTION
My solution was the following:
- in the main folder
qcc, create a folder calledexternal: - move
python.BUILDandnumpy.BUILDfromqcctoqcc/external - then modify the
WORKSPACEscript as follows:
new_local_repository(
name = "third_party_python",
build_file = "//external:python.BUILD",
path = "/usr/include/python3.10",
)
new_local_repository(
name = "third_party_numpy",
build_file = "//external:numpy.BUILD",
path = "/usr/local/lib/python3.10/dist-packages/numpy/core/",
)
This solved the issue for me. Hope this was helpful, have a greate day :)
Thanks for letting me know, Andrea!
I can confirm that this appears to be a bazel 7.x problem. I checked the Google internal code base to see whether anything changed around workspace_dir but it didn't appear so. Nevertheless, something is off. I'm also reading that WORKSPACE will be deprecated in version 8.x and beyond. Fun ;-)
I will check whether your change works with the older versions of bazel and if it does I'll change the default (and will give you credit on the github :-)
Thanks again! Robert
On Sat, Jan 6, 2024 at 7:16 AM Andrea Novellini @.***> wrote:
I am using Linux Ubuntu 22.04.3 LTS (WSL 2) on a windows 11 machine and I have python 3.10, numpy 1.26.3 and bazel 7.0.0 installed. I modified the WORKSPACE script according to my path to python and numpy, which are respectively: /usr/include/python3.10 /usr/local/lib/python3.10/dist-packages/numpy/core/
However, when I go in qcc/src/lib and try to build using bazel build all I got this error:
ERROR: /home/username/qcc/WORKSPACE:1:21: //external:third_party_python: invalid label '/home/username/qcc/python.BUILD' in attribute 'build_file' in 'new_local_repository' rule: invalid target name '/home/username/qcc/python.BUILD': target names may not start with '/' ERROR: /home/username/qcc/WORKSPACE:8:21: //external:third_party_numpy: invalid label '/home/username/qcc/numpy.BUILD' in attribute 'build_file' in 'new_local_repository' rule: invalid target name '/home/username/qcc/numpy.BUILD': target names may not start with '/' ERROR: Error computing the main repository mapping: Encountered error while reading extension file 'toolchains/jdk_build_file.bzl': no such package '@@rules_java_builtin//toolchains': error loading package 'external': Could not load //external package SOLUTION
My solution was the following:
- in the main folder qcc, create a folder called external:
- move python.BUILD and numpy.BUILD from qcc to qcc/external
- then modify the WORKSPACE script as follows:
new_local_repository( name = "third_party_python", build_file = "//external:python.BUILD", path = "/usr/include/python3.10", )
new_local_repository( name = "third_party_numpy", build_file = "//external:numpy.BUILD", path = "/usr/local/lib/python3.10/dist-packages/numpy/core/", )
This solved the issue for me. Hope this was helpful, have a greate day :)
— Reply to this email directly, view it on GitHub https://github.com/qcc4cp/qcc/issues/21, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEWY3BWTGZDAZ2S7RIVJJTYNFTD3AVCNFSM6AAAAABBPTYYDOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA3DQNRXGU4DGNA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
-- Robert Hundt