Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bazel build error for 'android_arm64' #5540

Closed
Ramees025 opened this issue Jul 22, 2024 · 7 comments
Closed

bazel build error for 'android_arm64' #5540

Ramees025 opened this issue Jul 22, 2024 · 7 comments
Assignees
Labels
os:linux-non-arm Issues on linux distributions which run on x86-64 architecture. DOES NOT include ARM devices. platform:c++ Issues specific to C++ framework in mediapipe task:LLM inference Issues related to MediaPipe LLM Inference Gen AI setup type:build/install For Build and Installation issues

Comments

@Ramees025
Copy link

OS Platform and Distribution

Ubuntu

Compiler version

No response

Programming Language and version

c++

Installed using virtualenv? pip? Conda?(if python)

No response

MediaPipe version

No response

Bazel version

No response

XCode and Tulsi versions (if iOS)

No response

Android SDK and NDK versions (if android)

r21e

Android AAR (if android)

None

OpenCV version (if running on desktop)

No response

Describe the problem

ERROR: An error occurred during the fetch of repository 'androidndk':

Complete Logs

When running below command, 
bazel build --cxxopt=-DABSL_FLAGS_STRIP_NAMES=0 -c opt --config=android_arm64 mediapipe/tasks/cc/genai/inference/c:llm_inference_engine_cpu_main

I am getting below error,

test@NEURAL-PLATFORM:~/ARM/mediapipe$ bazel build --cxxopt=-DABSL_FLAGS_STRIP_NAMES=0 -c opt --config=android_arm64 mediapipe/tasks/cc/genai/inference/c:llm_inference_engine_cpu_main
INFO: Build options --compilation_mode, --cpu, --crosstool_top, and 5 more have changed, discarding analysis cache.
INFO: Repository androidndk instantiated at:
  /home/test/ARM/mediapipe/WORKSPACE:713:23: in <toplevel>
Repository rule android_ndk_repository defined at:
  /home/test/.cache/bazel/_bazel_test/595332dd80a1b8d4c4daca7eb4d09658/external/rules_android_ndk/rules.bzl:127:41: in <toplevel>
ERROR: An error occurred during the fetch of repository 'androidndk':
   Traceback (most recent call last):
        File "/home/test/.cache/bazel/_bazel_test/595332dd80a1b8d4c4daca7eb4d09658/external/rules_android_ndk/rules.bzl", line 49, column 21, in _android_ndk_repository_impl
                _create_symlinks(ctx, ndk_path, clang_directory, sysroot_directory)
        File "/home/test/.cache/bazel/_bazel_test/595332dd80a1b8d4c4daca7eb4d09658/external/rules_android_ndk/rules.bzl", line 116, column 24, in _create_symlinks
                ctx.symlink(p, repo_relative_path)
Error in symlink: Cannot write outside of the repository directory for path /home/test/Android/Sdk/ndk-bundle/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/libexec
ERROR: /home/test/ARM/mediapipe/WORKSPACE:713:23: fetching android_ndk_repository rule //external:androidndk: Traceback (most recent call last):
        File "/home/test/.cache/bazel/_bazel_test/595332dd80a1b8d4c4daca7eb4d09658/external/rules_android_ndk/rules.bzl", line 49, column 21, in _android_ndk_repository_impl
                _create_symlinks(ctx, ndk_path, clang_directory, sysroot_directory)
        File "/home/test/.cache/bazel/_bazel_test/595332dd80a1b8d4c4daca7eb4d09658/external/rules_android_ndk/rules.bzl", line 116, column 24, in _create_symlinks
                ctx.symlink(p, repo_relative_path)
Error in symlink: Cannot write outside of the repository directory for path /home/test/Android/Sdk/ndk-bundle/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/libexec
INFO: Repository flatbuffers instantiated at:
  /home/test/ARM/mediapipe/WORKSPACE:284:12: in <toplevel>
  /home/test/ARM/mediapipe/third_party/flatbuffers/workspace.bzl:6:29: in repo
Repository rule third_party_http_archive defined at:
  /home/test/ARM/mediapipe/third_party/repo.bzl:132:43: in <toplevel>
INFO: Repository com_google_sentencepiece instantiated at:
  /home/test/ARM/mediapipe/WORKSPACE:305:13: in <toplevel>
Repository rule http_archive defined at:
  /home/test/.cache/bazel/_bazel_test/595332dd80a1b8d4c4daca7eb4d09658/external/bazel_tools/tools/build_defs/repo/http.bzl:372:31: in <toplevel>
ERROR: /home/test/ARM/mediapipe/WORKSPACE:714:5: //external:android/crosstool depends on @androidndk//:toolchain in repository @androidndk which failed to fetch. no such package '@androidndk//': Cannot write outside of the repository directory for path /home/test/Android/Sdk/ndk-bundle/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/libexec
ERROR: Analysis of target '//mediapipe/tasks/cc/genai/inference/c:llm_inference_engine_cpu_main' failed; build aborted:
INFO: Elapsed time: 3.032s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (4 packages loaded, 220 targets configured)
    currently loading: mediapipe/tasks/cc/genai/inference/utils/xnn_utils
    Fetching repository @com_github_glog_glog_no_gflags; starting
    Fetching /home/test/.cache/bazel/_bazel_test/595332dd80a1b8d4c4daca7eb4d09658/external/com_github_glog_glog_no_gflags; Extracting v0.6.0.tar.gz

Any idea how to solve this?
@Ramees025 Ramees025 added the type:build/install For Build and Installation issues label Jul 22, 2024
@Ramees025
Copy link
Author

ERROR: An error occurred during the fetch of repository 'androidndk':
Traceback (most recent call last):
File "/home/test/.cache/bazel/_bazel_test/595332dd80a1b8d4c4daca7eb4d09658/external/rules_android_ndk/rules.bzl", line 49, column 21, in _android_ndk_repository_impl
_create_symlinks(ctx, ndk_path, clang_directory, sysroot_directory)
File "/home/test/.cache/bazel/_bazel_test/595332dd80a1b8d4c4daca7eb4d09658/external/rules_android_ndk/rules.bzl", line 116, column 24, in _create_symlinks
ctx.symlink(p, repo_relative_path)
Error in symlink: Cannot write outside of the repository directory for path /home/test/Android/Sdk/ndk-bundle/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/libexec

@kuaashish kuaashish assigned kuaashish and unassigned ayushgdev Jul 23, 2024
@kuaashish kuaashish added os:linux-non-arm Issues on linux distributions which run on x86-64 architecture. DOES NOT include ARM devices. platform:c++ Issues specific to C++ framework in mediapipe task:LLM inference Issues related to MediaPipe LLM Inference Gen AI setup labels Jul 23, 2024
@kuaashish
Copy link
Collaborator

Hi @Ramees025,

Please run this command after navigating to the MediaPipe cloned repository on your local machine and let us know if you can build it successfully.

chmod +x setup_android_sdk_and_ndk.sh
./setup_android_sdk_and_ndk.sh

Thank you!!

@kuaashish kuaashish added the stat:awaiting response Waiting for user response label Jul 23, 2024
@Siddharth-Latthe-07
Copy link

The error message you're encountering suggests that Bazel is attempting to create symlinks outside of the repository directory, which is not allowed.
Steps to resolve the issue:-

  1. Check NDK Path:
    Ensure that the NDK path in your WORKSPACE file is correctly set and points to a valid NDK installation. The path should not include the symlinks that Bazel is attempting to create.
android_ndk_repository(
    name = "androidndk",
    path = "/home/test/Android/Sdk/ndk/21.4.7075529",  # Update with your actual path
)
  1. Update NDK
  2. Check Permissions:
    Ensure that you have the necessary permissions to access and write to the directories involved. This includes the Bazel cache directory and the NDK directory.
sudo chown -R $(whoami) /home/test/Android/Sdk/ndk-bundle
sudo chown -R $(whoami) /home/test/.cache/bazel

4.Use Correct Bazel Version:
Ensure you are using a compatible version of Bazel. MediaPipe might require a specific version. Check MediaPipe's documentation for the recommended Bazel version and install it.
5, Clean Bazel Cache:
Sometimes, Bazel's cache might be corrupted or outdated. Cleaning the cache might resolve the issue.

bazel clean --expunge
  1. Check WORKSPACE Configuration:
    Ensure your WORKSPACE file has the correct configuration for the Android NDK.
    sample snippet:-
android_ndk_repository(
    name = "androidndk",
    path = "/home/test/Android/Sdk/ndk/21.4.7075529",  # Update this path
    api_level = 21  # Or your desired API level
)
  1. lastly, Final Command
    Once all configurations are corrected, try running the build command again:
bazel build --cxxopt=-DABSL_FLAGS_STRIP_NAMES=0 -c opt --config=android_arm64 mediapipe/tasks/cc/genai/inference/c:llm_inference_engine_cpu_main

Hope this helps, Thanks

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Waiting for user response label Jul 25, 2024
@kuaashish
Copy link
Collaborator

Hi @Ramees025.

Can you please go through the above comment #5540 (comment) and let us know the status of this?

Thank you!!

@kuaashish kuaashish added the stat:awaiting response Waiting for user response label Jul 29, 2024
Copy link

github-actions bot commented Aug 6, 2024

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Aug 6, 2024
Copy link

This issue was closed due to lack of activity after being marked stale for past 7 days.

Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@kuaashish kuaashish removed stat:awaiting response Waiting for user response stale labels Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os:linux-non-arm Issues on linux distributions which run on x86-64 architecture. DOES NOT include ARM devices. platform:c++ Issues specific to C++ framework in mediapipe task:LLM inference Issues related to MediaPipe LLM Inference Gen AI setup type:build/install For Build and Installation issues
Projects
None yet
Development

No branches or pull requests

4 participants