Unable to build bazel project: no such package '#io_bazel_rules_kotlin//kotlin' - kotlin

OS:
daz#daz:/rom/aosp-mirror/android-test$ uname -ar
Linux daz 5.4.0-28-generic #32-Ubuntu SMP Wed Apr 22 17:40:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Building with bazel-2.2.0 with the target in the code below:
daz#daz:/rom/aosp-mirror/android-test$ bazel-2.2.0 build :axt_m2repository
I am trying to build the android-test repo here:
https://github.com/android/android-test
The definition for these rules appears to be this:
# Kotlin toolchains
rules_kotlin_version = "4c71740a1b63b785fc90afd8d4d4d5bfda527107"
http_archive(
name = "io_bazel_rules_kotlin",
sha256 = "c0ca7b66d9f466067635482592634703bf0a648d51ec958f41796d43ca8256b3",
strip_prefix = "rules_kotlin-%s" % rules_kotlin_version,
type = "zip",
urls = ["https://github.com/bazelbuild/rules_kotlin/archive/%s.zip" % rules_kotlin_version],
)
load("#io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains")
kotlin_repositories()
kt_register_toolchains()
But I get the following exception when trying to build:
ERROR: error loading package '': Encountered error while reading extension file 'kotlin/kotlin.bzl': no such package '#io_bazel_rules_kotlin//kotlin': error loading package 'external': Could not load //external package
The full output is here:
ERROR: /home/daz/.cache/bazel/_bazel_daz/ff62db25b941d7730a4c94ee1d6f2c41/external/robolectric/bazel/robolectric.bzl:2:5: Traceback (most recent call last):
File "/rom/aosp-mirror/android-test/WORKSPACE", line 130
robolectric_repositories()
File "/home/daz/.cache/bazel/_bazel_daz/ff62db25b941d7730a4c94ee1d6f2c41/external/robolectric/bazel/robolectric.bzl", line 381, in robolectric_repositories
android_all_jars()
File "/home/daz/.cache/bazel/_bazel_daz/ff62db25b941d7730a4c94ee1d6f2c41/external/robolectric/bazel/robolectric.bzl", line 2, in android_all_jars
native.maven_jar
no native function or rule 'maven_jar'
Available attributes: aar_import, action_listener, alias, android_binary, android_device, android_device_script_fixture, android_host_service_fixture, android_instrumentation_test, android_library, android_local_test, android_ndk_repository, android_sdk, android_sdk_repository, android_tools_defaults_jar, apple_binary, apple_cc_toolchain, apple_static_library, available_xcodes, bazel_version, bind, cc_binary, cc_host_toolchain_alias, cc_import, cc_libc_top_alias, cc_library, cc_proto_library, cc_test, cc_toolchain, cc_toolchain_alias, cc_toolchain_suite, config_feature_flag, config_setting, constraint_setting, constraint_value, environment, existing_rule, existing_rules, exports_files, extra_action, fdo_prefetch_hints, fdo_profile, filegroup, genquery, genrule, glob, j2objc_library, java_binary, java_import, java_library, java_lite_proto_library, java_package_configuration, java_plugin, java_proto_library, java_runtime, java_runtime_alias, java_test, java_toolchain, java_toolchain_alias, label_flag, label_setting, local_config_platform, local_repository, new_local_repository, ninja_build, ninja_graph, objc_import, objc_library, package_group, package_name, platform, proto_lang_toolchain, proto_library, py_binary, py_library, py_runtime, py_test, register_execution_platforms, register_toolchains, repository_name, sh_binary, sh_library, sh_test, test_suite, toolchain, toolchain_type, xcode_config, xcode_config_alias, xcode_version
ERROR: error loading package '': Encountered error while reading extension file 'kotlin/kotlin.bzl': no such package '#io_bazel_rules_kotlin//kotlin': error loading package 'external': Could not load //external package
INFO: Elapsed time: 0.061s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
WORKAROUND
Build branch:
androidx-test-1.3.0-beta01
Use bazel-2.2.0
bazel-2.2.0 build :axt_m2repository
This is the related issue in the android-test github issue tracker:
https://github.com/android/android-test/issues/626

Make sure that you're using the latest version of Bazel and the android-test repo.
The maven_jar native rule was removed in Bazel 2.0 (Bazel tracking ticket). Have you tried building with a Bazel version < 2.0 (e.g. 1.2.1)?

Related

Error installing MoveIt 2 from source on Ubuntu 20.04 VM

I'm trying to get involved in open source and also am quite interested in robotics, so I thought about contributing to MoveIt 2. As a first step, I'm installing MoveIt 2 from source on my Ubuntu 20.04 VM in VirtualBox.
I've run through all the instructions here: https://moveit.ros.org/install-moveit2/source/#:~:text=colcon%20build%20%2D%2Devent%2Dhandlers%20desktop_notification%2D%20status%2D%20%2D%2Dcmake%2Dargs%20%2DDCMAKE_BUILD_TYPE%3DRelease
However, the build is failing on the highlighted part. The error message is as follows:
Starting >>> geometric_shapes
--- stderr: geometric_shapes
CMake Error at CMakeLists.txt:47 (find_package):
By not providing "Findeigen3_cmake_module.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"eigen3_cmake_module", but CMake did not find one.
Could not find a package configuration file provided by
"eigen3_cmake_module" with any of the following names:
eigen3_cmake_moduleConfig.cmake
eigen3_cmake_module-config.cmake
Add the installation prefix of "eigen3_cmake_module" to CMAKE_PREFIX_PATH
or set "eigen3_cmake_module_DIR" to a directory containing one of the above
files. If "eigen3_cmake_module" provides a separate development package or
SDK, be sure it has been installed.
---
Failed <<< geometric_shapes [1.20s, exited with code 1]
Summary: 0 packages finished [1.46s]
1 package failed: geometric_shapes
1 package had stderr output: geometric_shapes
33 packages not processed
Any help is really appreciated. Thanks!
You have to install ROS2 before building Move It 2. After installing the ROS2 binaries, the error doesn't occur.

Building TensorFlow 2 with bazel 0.29.1 on Windows 10 fails

Trying to compile TF 2.0 with Bazel, ends up in a failure.
I am struggling this issue for quite a while, looked it up online, but haven't found any solution to the exact problem. Several running configuration (with or w/o Cuda, with or w/o creating zip file, etc) eventually leading to the same failure.
System information:
OS Platform and Distribution (Windows 10)
TensorFlow installed from (source)
TensorFlow version: 2.0 (master branch on 07 Nov 2019, to be exact)
Python version: 3.7
Installed using virtualenv? pip? conda?: No
Bazel version (if compiling from source): 0.29.1
GCC/Compiler version (if compiling from source): 8.1.0
CUDA/cuDNN version: 10.0/7
GPU model and memory: GeForce GTX 1050 15.88 GB RAM
My actions:
1. git checkout master (in the TF git repo)
2. bazel clean
3. configure (all defaults except for python path and Cuda)
4. bazel build --config=cuda --define=no_tensorflow_py_deps=true tensorflow:tensorflow_cc.dll
Failure message:
ERROR: C:/users/shahar/git/tensorflow/tensorflow/core/BUILD:2537:1:
Executing genrule //tensorflow/core:version_info_gen failed (Exit 5)
LAUNCHER ERROR: Cannot launch process: "C:/Program
Files/WindowsApps/PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0/python.exe"
C:\users\shahar_bazel_shahar\duchsbgv\execroot\org_tensorflow\bazel-out\x64_windows-opt\bin\tensorflow\tools\git\gen_git_source.zip
--generate external/local_config_git/gen/spec.json external/local_config_git/gen/head
external/local_config_git/gen/branch_ref
bazel-out/x64_windows-opt/bin/tensorflow/core/util/version_info.cc
--git_tag_override= Reason: (error: 5): Access is denied.
What am i doing wrong?
Edit:
added a junction with #László advice:
mklink /j c:\python "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0"
and used it when "configure" asked me to, for both python.exe and the libs, yet the error remains. details:
ERROR: C:/users/shahar/git/tensorflow/tensorflow/core/BUILD:2537:1:
Executing genrule //tensorflow/core:version_info_gen failed (Exit 5)
LAUNCHER ERROR: Cannot launch process: "C:/python/python.exe"
C:\users\shahar_bazel_shahar\duchsbgv\execroot\org_tensorflow\bazel-out\x64_windows-opt\bin\tensorflow\tools\git\gen_git_source.zip
--generate external/local_config_git/gen/spec.json external/local_config_git/gen/head
external/local_config_git/gen/branch_ref
bazel-out/x64_windows-opt/bin/tensorflow/core/util/version_info.cc
--git_tag_override= Reason: (error: 5): Access is denied.
Edit_2:
Again with #László help:
I ran:
bazel info execution_root
got a path, cd into it.
From there i ran:
c:\python\python.exe c:\users\shahar\_bazel_shahar\duchsbgv\execroot\org_tensorflow\bazel-out\x64_windows-opt\bin\tensorflow\tools\git\gen_git_source.zip --generate external/local_config_git/gen/spec.json external/local_config_git/gen/head external/local_config_git/gen/branch_ref c:\tmp\foo.cc --git_tag_override=
and got the following error message:
Traceback (most recent call last): File
"\?\C:\Users\Shahar\AppData\Local\Temp\Bazel.runfiles_ltu2ig_a\runfiles\org_tensorflow\tensorflow\tools\git\gen_git_source.py",
line 340, in
generate(args.generate, args.git_tag_override) File "\?\C:\Users\Shahar\AppData\Local\Temp\Bazel.runfiles_ltu2ig_a\runfiles\org_tensorflow\tensorflow\tools\git\gen_git_source.py",
line 273, in generate
write_version_info(dest_file, git_version) File "\?\C:\Users\Shahar\AppData\Local\Temp\Bazel.runfiles_ltu2ig_a\runfiles\org_tensorflow\tensorflow\tools\git\gen_git_source.py",
line 228, in write_version_info
open(filename, "w").write(contents) FileNotFoundError: [Errno 2] No such file or directory: 'c:\tmp\foo.cc'
I suspect the space in the Python path.
Try this:
open cmd.exe
create a junction c:\python pointing to the real Python directory:
mklink /j c:\python "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0"
You can use any other path than c:\python, just make sure there's no space or special characters in it.
run ./configure.py again, use c:\python

Tensorflow 1.9 Bazel build error with Cuda on Windows

I'm trying to compile a sample program which uses Tensorflow core, with CUDA support on Windows 10 64bit via Bazel on the following environments:
Windows 10 64 bit
CUDA Toolkit 9.0
CUDNN 9.0
Tensorflow 1.9
Bazel 0.16
I went through the configure.py successfully, I added the CUDA and the CUDNN location.
This is my Bazel BUILD file:
cc_binary(
name = "mnistpredict.dll",
srcs = ["mnist.cc", "MNIST.h"],
deps = [
"//tensorflow/core:tensorflow",
],
linkshared=1
)
I try to compile with this command:
bazel build //tensorflow/loadgraph:mnistpredict.dll
ERROR:
C:/users/laci/downloads/tensorflow-1.9.0/tensorflow/loadgraph/BUILD:1:1:
error loading package 'tensorflow/core': Encountered error while
reading extension file 'cuda/build_defs.bzl': no such package
'#local_config_cuda//cuda': Traceback (most recent call last):
File "C:/users/laci/downloads/tensorflow-1.9.0/third_party/gpus/cuda_configure.bzl",
line 1166
_create_local_cuda_repository(repository_ctx)
File "C:/users/laci/downloads/tensorflow-1.9.0/third_party/gpus/cuda_configure.bzl",
line 995, in _create_local_cuda_repository
_get_cuda_config(repository_ctx)
File "C:/users/laci/downloads/tensorflow-1.9.0/third_party/gpus/cuda_configure.bzl",
line 750, in _get_cuda_config
_cudnn_version(repository_ctx, cudnn_install_base..., ...)
File "C:/users/laci/downloads/tensorflow-1.9.0/third_party/gpus/cuda_configure.bzl",
line 466, in _cudnn_version
find_cuda_define(repository_ctx, cudnn_header_dir, "c...", ...)
File "C:/users/laci/downloads/tensorflow-1.9.0/third_party/gpus/cuda_configure.bzl",
line 422, in find_cuda_define
auto_configure_fail(("Error reading %s: %s" % (str(h...)))
File "C:/users/laci/downloads/tensorflow-1.9.0/third_party/gpus/cuda_configure.bzl",
line 210, in auto_configure_fail
fail(("\n%sCuda Configuration Error:%...)))
Cuda Configuration Error: Error reading
C:/Users/laci/Downloads/cudnn-9.0-windows10-x64-v7.1/cuda/include/cudnn.h:
java.io.IOException: ERROR:
src/main/native/windows/processes-jni.cc(239): CreateProcessW("grep"
--color=never -A1 -E "#define CUDNN_MAJOR" C:/Users/laci/Downloads/cudnn-9.0-windows10-x64-v7.1/cuda/include/cudnn.h):
The system cannot find the file specified.
and referenced by '//tensorflow/loadgraph:mnistpredict.dll' ERROR:
Analysis of target '//tensorflow/loadgraph:mnistpredict.dll' failed;
build aborted: Analysis failed INFO: Elapsed time: 1.612s INFO: 0
processes. FAILED: Build did NOT complete successfully (2 packages
loaded)
currently loading: tensorflow/core
When I try it without CUDA support, I can compile it successfully.
It was looking for grep.exe under %PATH% but failed. Either adding Git\bin to %PATH% or install grep for Windows will do the trick.
It had taken me several days to finally build a tensorflow-gpu 1.10 whl on Windows 7 64 bit with bazel + msys2.

bazel - Error building TensorFlow with local LLVM repository

Essentially, I want to run TensorFlow with a custom LLVM repository and not the llvm-mirror that bazel pulls from.
I made the following changes:
Changed the temp_workaround_http_archive rule in //tensorflow/workspace.bzl to:
native.local_repository (
name = "llvm",
path = "/git/llvm/",
)
In /git/llvm I added the file WORKSPACE containing:
workspace( name = "llvm" )
However, I know that an llvm.build file is required, but since I am new to bazel, I am not sure where it should be located.
I am getting the following error log:
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
ERROR: /git/tensorflow/tensorflow/tools/pip_package/BUILD:81:1: no such package '#llvm//': BUILD file not found on package path and referenced by '//tensorflow/tools/pip_package:licenses'.
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted.
INFO: Elapsed time: 0.219s
I installed TensorFlow from source. Here is the version info:
$ git rev-parse HEAD
4c3bb1aeb7bb46bea35036433742a720f39ce348
$ bazel version
Build label: 0.4.5
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Mar 16 12:19:38 2017 (1489666778)
Build timestamp: 1489666778
Build timestamp as int: 1489666778
Thanks in advance for the help!
Found the fix. Quite simple actually.
The local_repository rule in bazel is for external bazel repositories only. To use a non-bazel external repository, we need to use new_local_repository which takes build_file as an argument.
You can use the http server function of python to build a local file server, like:
python3 -m http.server
Then edit the file "tensorflow/workspace.bzl"
tf_http_archive(
name = "llvm",
urls = [
"https://mirror.bazel.build/**/195a164675af86f390f9816e53291013d1b551d7.tar.gz",
"http://localhost:8000/195a164675af86f390f9816e53291013d1b551d7.tar.gz",
"https://github.com/**/195a164675af86f390f9816e53291013d1b551d7.tar.gz",
],
sha256 = "57a8333f8e6095d49f1e597ca18e591aba8a89d417f4b58bceffc5fe1ffcc02b",
strip_prefix = "llvm-195a164675af86f390f9816e53291013d1b551d7",
build_file = str(Label("//third_party/llvm:llvm.BUILD")),
)
Add one local file path in the middle line of urls, and then rebuild it again.

Errors when downloading emscripten

I want to download emscripten on ubuntu 12.04.I downloaded Cmake 3.3.0 then I download esmscripten_portable and I run these commands:
# Fetch the latest registry of available tools.
./emsdk update
# Download and install the latest SDK tools.
./emsdk install latest
I got these error messages:
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
-- OCaml bindings disabled.
CMake Error at cmake/modules/HandleLLVMOptions.cmake:17 (message):
Host GCC version must be at least 4.7!
Call Stack (most recent call first):
CMakeLists.txt:378 (include)
-- Configuring incomplete, errors occurred!
See also "/home/slim/Bureau/emsdk_portable/clang/tag-e1.34.3/build_tag-e1.34.3_32/CMakeFiles/CMakeOutput.log".
See also "/home/slim/Bureau/emsdk_portable/clang/tag-e1.34.3/build_tag-e1.34.3_32/CMakeFiles/CMakeError.log".
CMake invocation failed due to exception!
Working directory: /home/slim/Bureau/emsdk_portable/clang/tag-e1.34.3/build_tag-e1.34.3_32
Command '['cmake', '-G', 'Unix Makefiles', '-DCMAKE_BUILD_TYPE=RelWithDebInfo', '-DPYTHON_EXECUTABLE=/usr/bin/python', '-DLLVM_TARGETS_TO_BUILD=X86;JSBackend', '-DLLVM_INCLUDE_EXAMPLES=OFF', '-DLLVM_INCLUDE_TESTS=OFF', '-DCLANG_INCLUDE_EXAMPLES=OFF', '-DCLANG_INCLUDE_TESTS=OFF', '/home/slim/Bureau/emsdk_portable/clang/tag-e1.34.3/src']' returned non-zero exit status 1
Installation failed!
I installed all these libraries very well but when I run this command:./emsdk activate latest.I got this message:The Emscripten configuration file /home/slim/.emscripten has been rewritten with the following contents:
import os
SPIDERMONKEY_ENGINE = ''
NODE_JS = 'node'
LLVM_ROOT='/home/slim/Bureau/emsdk_portable/clang/tag-e1.34.3/build_tag-e1.34.3_32/bin'
EMSCRIPTEN_ROOT='/home/slim/Bureau/emsdk_portable/emscripten/tag-1.34.3'
EMSCRIPTEN_NATIVE_OPTIMIZER='/home/slim/Bureau/emsdk_portable/emscripten/tag-1.34.3_32bit_optimizer/optimizer'
V8_ENGINE = ''
TEMP_DIR = '/tmp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]
To conveniently access the selected set of tools from the command line, consider adding the following directories to PATH, or call 'source ./emsdk_env.sh' to do this for you.
/home/slim/Bureau/emsdk_portable:/home/slim/Bureau/emsdk_portable/clang/tag-e1.34.3/build_tag-e1.34.3_32/bin:/home/slim/Bureau/emsdk_portable/emscripten/tag-1.34.3
I run :
source ./emsdk_env.sh
But when I run the command :
./emcc v
I got :
bash: ./emcc: No such file or directory