-
Notifications
You must be signed in to change notification settings - Fork 141
fix(build): correct docker build process for mobile sandbox #353
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
Merged
rayrayraykk
merged 2 commits into
agentscope-ai:main
from
XiuShenAl:fix/mobile-sandbox-build
Feb 6, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
src/agentscope_runtime/sandbox/box/mobile/box/host_checker.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # -*- coding: utf-8 -*- | ||
| import platform | ||
| import subprocess | ||
| import logging | ||
|
|
||
|
|
||
| class HostPrerequisiteError(Exception): | ||
| """Exception raised when host prerequisites | ||
| for MobileSandbox are not met.""" | ||
|
|
||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def check_mobile_sandbox_host_readiness() -> None: | ||
| """ | ||
| Performs a check of the host environment to ensure it has the necessary | ||
| modules (like binder_linux) to run the MobileSandbox. | ||
| """ | ||
|
XiuShenAl marked this conversation as resolved.
|
||
| logger.info( | ||
| "Performing host environment check for MobileSandbox readiness...", | ||
| ) | ||
|
|
||
| architecture = platform.machine().lower() | ||
| if architecture in ("aarch64", "arm64"): | ||
| logger.warning( | ||
| "\n======================== WARNING ========================\n" | ||
| "ARM64/aarch64 architecture detected (e.g., Apple M-series).\n" | ||
| "Running this mobile sandbox on a non-x86_64 host may lead \n" | ||
| " to unexpected compatibility or performance issues.\n" | ||
| "=========================================================", | ||
| ) | ||
|
|
||
| os_type = platform.system() | ||
| if os_type == "Linux": | ||
| try: | ||
| result = subprocess.run( | ||
| ["lsmod"], | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| ) | ||
| loaded_modules = result.stdout | ||
| except (FileNotFoundError, subprocess.CalledProcessError): | ||
| loaded_modules = "" | ||
| logger.warning( | ||
| "Could not execute 'lsmod' to verify kernel modules.", | ||
| ) | ||
|
|
||
| if "binder_linux" not in loaded_modules: | ||
| error_message = ( | ||
| "\n========== HOST PREREQUISITE FAILED ==========\n" | ||
| "MobileSandbox requires specific kernel modules" | ||
| " that appear to be missing or not loaded.\n\n" | ||
| "To fix this, please run the following commands" | ||
| " on your Linux host:\n\n" | ||
| "## Install required kernel modules\n" | ||
| "sudo apt update" | ||
| " && sudo apt install -y linux-modules-extra-`uname -r`\n" | ||
| "sudo modprobe binder_linux" | ||
| ' devices="binder,hwbinder,vndbinder"\n' | ||
| "## (Optional) Load the ashmem driver for older kernels\n" | ||
| "sudo modprobe ashmem_linux\n" | ||
| "==================================================" | ||
| ) | ||
| raise HostPrerequisiteError(error_message) | ||
|
|
||
| if os_type == "Windows": | ||
| try: | ||
| result = subprocess.run( | ||
| ["wsl", "lsmod"], | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| encoding="utf-8", | ||
| ) | ||
| loaded_modules = result.stdout | ||
| except (FileNotFoundError, subprocess.CalledProcessError): | ||
| loaded_modules = "" | ||
| logger.warning( | ||
| "Could not execute 'wsl lsmod' to verify kernel modules.", | ||
| ) | ||
|
|
||
| if "binder_linux" not in loaded_modules: | ||
| error_message = ( | ||
| "\n========== HOST PREREQUISITE FAILED ==========\n" | ||
| "MobileSandbox on Windows requires Docker Desktop " | ||
| "with the WSL 2 backend.\n" | ||
| "The required kernel modules seem to be missing " | ||
| "in your WSL 2 environment.\n\n" | ||
| "To fix this, please follow these steps:\n\n" | ||
| "1. **Ensure Docker Desktop is using WSL 2**:\n" | ||
| " - Open Docker Desktop -> Settings -> General.\n" | ||
| " - Make sure 'Use the WSL 2 based engine' " | ||
| "is checked.\n\n" | ||
| "2. **Ensure WSL is installed and updated**:\n" | ||
| " - Open PowerShell or Command Prompt " | ||
| "as Administrator.\n" | ||
| " - Run: wsl --install\n" | ||
| " - Run: wsl --update\n" | ||
| " (An update usually installs a recent Linux kernel " | ||
| "with the required modules.)\n\n" | ||
| "3. **Verify manually (Optional)**:\n" | ||
| " - After updating, run 'wsl lsmod | findstr binder' " | ||
| "in your terminal.\n" | ||
| " - If it shows 'binder_linux', " | ||
| "the issue should be resolved.\n" | ||
| "==================================================" | ||
| ) | ||
| raise HostPrerequisiteError(error_message) | ||
|
|
||
| logger.info("Host environment check passed.") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.