惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Securelist
有赞技术团队
有赞技术团队
WordPress大学
WordPress大学
V
V2EX
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
The Register - Security
The Register - Security
Recorded Future
Recorded Future
Y
Y Combinator Blog
小众软件
小众软件
Jina AI
Jina AI
V2EX - 技术
V2EX - 技术
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
宝玉的分享
宝玉的分享
The Hacker News
The Hacker News
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
T
Threatpost
博客园 - 聂微东
Scott Helme
Scott Helme
IT之家
IT之家
N
Netflix TechBlog - Medium
T
The Exploit Database - CXSecurity.com
S
Schneier on Security
MongoDB | Blog
MongoDB | Blog
T
Tor Project blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
About on SuperTechFans
酷 壳 – CoolShell
酷 壳 – CoolShell
C
CERT Recently Published Vulnerability Notes
P
Palo Alto Networks Blog
Spread Privacy
Spread Privacy
C
Check Point Blog
L
LINUX DO - 最新话题
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Last Week in AI
Last Week in AI
Attack and Defense Labs
Attack and Defense Labs
T
Tailwind CSS Blog
罗磊的独立博客
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Webroot Blog
Webroot Blog
Help Net Security
Help Net Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
PCI Perspectives
PCI Perspectives
Security Latest
Security Latest

阿尔的代码屋 | 全栈技术笔记

VS Code 连接 WSL 精确每 10 分钟掉线 排坑笔记 | 阿尔的代码屋 Android 模拟器代理联网与 No Internet WiFi 锁死排坑笔记 | 阿尔的代码屋 [object Object] typing_extensions 有用(四):使用 TypeIs 替代危险的 cast,做最严谨的类型收窄 | 阿尔的代码屋 GoRouter 结合 Isar 运行 Widget 测试并发/粘性线程死锁卡死排坑笔记 | 阿尔的代码屋 typing_extensions 有用(三):使用 Unpack 结合 TypedDict 给 **kwargs 装上透视眼 | 阿尔的代码屋 typing_extensions 有用(二):使用 @override 打造重构代码时的“防呆神器” | 阿尔的代码屋 Flutter 并发测试踩坑实录 - IsarCore 动态库下载冲突与 Widget 测试 HTTP 拦截全链路解决 | 阿尔的代码屋 typing_extensions 有用(一):使用 Self 终结继承时的类型推断灾难 | 阿尔的代码屋 基于 Cloudflare Pages 的纯前端 WebAssembly 应用自动化部署实践 | 开发日志 | 阿尔的代码屋 基于 VS Code 远程开发的 GPU Docker 容器自动清理方案实践 开发日志| 阿尔的代码屋 Patrol iOS 集成测试排坑实录 - xcodebuild exit code 70 全链路解决 | 阿尔的代码屋 Flutter E2E 测试从 integration_test 迁移到 Patrol - 实践笔记 | 阿尔的代码屋 Linux/macOS 下 micromamba 报错 Shard Index not available 与极度卡顿 排坑笔记 | 阿尔的代码屋 critical libmamba Shell not initialized micromamba报错 subprocess 无法修改父 Shell - 排坑笔记 | 阿尔的代码屋 VS Code Remote-SSH: 彻底告别重复输入密码 - 排坑笔记 | 阿尔的代码屋 Git 报警: inexact rename detection was skipped - 排坑笔记 | 阿尔的代码屋 解决群晖 NAS SSL 证书自动部署难题 | 阿尔的代码屋 Windows 下 Git error: fatal: refusing to work with credential missing host field - 排坑笔记 | 阿尔的代码屋 VS Code 调试 Python 第三方库源码的配置 - 开发技巧| 阿尔的代码屋 VS Code Remote Tunnels本地连接调试Kaggle GPU - 开发技巧| 阿尔的代码屋 Windows下Git error: open(xxxx) Filename too long - 排坑笔记 | 阿尔的代码屋 记录2026年零预约港卡开户实录避坑 告别孤岛:拥抱 MCP 协议,为大模型打造标准“USB 接口” - 大模型实战 08 完结篇 | 阿尔的代码屋 从 ReAct 到 Workflow:基于云端 API 构建事件驱动的智能体 - 大模型实战 07 额外篇 | 阿尔的代码屋 基于 LlamaIndex ReAct 框架手搓全自动博客监控 Agent - 大模型实战 07 | 阿尔的代码屋 在 Kaggle 上用 Unsloth 极速微调 Qwen3 - 大模型实战 06 | 阿尔的代码屋 大模型微调实战详解 - 大模型实战 05 | 阿尔的代码屋 基于 ChromaDB 打造工程级 RAG 系统 - 大模型实战 04 | 阿尔的代码屋 拆解 Transformers 原理与图解 - 大模型实战 03 | 阿尔的代码屋 云端炼丹房 2:Kaggle 上手指南 - 大模型实战 03预备 | 阿尔的代码屋 云端炼丹房:Google Colab 免费 GPU 上手指南 - 大模型实战 03预备 | 阿尔的代码屋 Open WebUI 部署与 RAG 实战 - 大模型实战 02 | 阿尔的代码屋
在 Android Termux 环境下安装 Hermes Agent 的踩坑与完美解决实践 开发日志| 阿尔的代码屋
Algieba · 2026-07-14 · via 阿尔的代码屋 | 全栈技术笔记

1. 业务场景与核心挑战

运行环境:

  • 操作系统:Android (基于 Termux 终端模拟器)
  • 开发工具:Python 3.13, Clang, Rust 工具链
  • 业务场景:在移动端设备上本地化部署并运行 Hermes Agent AI 代理工具。

核心挑战:
移动端 Termux 环境虽然提供了高度还原的 Linux 体验,但由于其底层依然依赖 Android 的 API 和特殊的包管理机制,在安装包含大量 C/Rust 扩展的复杂 Python 项目时,极其容易遭遇依赖缺失、编译死锁和平台兼容性阻断。


2. 官方一键脚本的初次尝试与死锁陷阱

踩坑重现:
起初,我尝试直接使用官方提供的一键安装脚本,期望能快速完成部署:

1
curl -fsSL [https://hermes-agent.nousresearch.com/install.sh](https://hermes-agent.nousresearch.com/install.sh) | bash

输出结果(异常卡死):

1
2
3
4
5
6
7
✓ Detected: android (termux)
→ Termux detected — using Python's stdlib venv + pip instead of uv
→ Checking Termux Python...
→ Installing Python via pkg...
date: /data/data/com.termux/cache/apt/pkgcache.bin: No such file or directory

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

脚本在输出最后一行警告后,便彻底失去响应,长时间假死。

原因剖析:
这是 Termux 下典型的管道符执行“暗坑”。官方安装脚本在后台调用了 pkgapt 来安装依赖,而包管理器在此刻弹出了类似 [Y/n] 的交互式确认提示。由于使用了 curl ... | bash 的无头执行方式,终端的交互界面被直接屏蔽,导致脚本在此处死锁等待,永远等不到用户的输入。

应对策略:
使用 Ctrl+C 强行打断死锁,改为手动执行带 -y 参数的静默更新与基础依赖安装:

1
2
pkg update && pkg upgrade -y
pkg install python git clang rust make -y

3. 突破网络连通性与命令行代理限制

跨过了基础依赖的坑后,再次运行安装脚本,结果又遭遇了网络相关的阻断。

输出结果(网络报错):

1
2
3
4
✓ Node.js v26.3.1 installed via pkg
→ Checking internet connectivity for package install and web tools...
⚠ Could not reach [https://duckduckgo.com/](https://duckduckgo.com/)
⚠ Termux network prerequisites may be incomplete.

紧接着,在脚本尝试静默安装 pkg-config libffi openssl 时,又一次因为 [Y/n] 提示陷入了卡死。

原因剖析:

  1. 根证书缺失: Termux 环境初始未携带完整的 CA 证书链,导致 HTTPS 请求被拒。
  2. 终端不走系统 VPN: Android 系统状态栏虽然显示梯子已连接,但 Termux 中的命令行工具(如 curl, pip)默认处于直连状态,无法穿透网络限制拉取国外资源。

应对策略:
补全证书和所有底层依赖,并手动注入本地代理端口的环境变量(假设代理软件的本地 HTTP 端口为 7890):

1
2
3
4
5
6
7
8
9
10

pkg install -y ca-certificates curl pkg-config libffi openssl ripgrep ffmpeg


export http_proxy="[http://127.0.0.1:7890](http://127.0.0.1:7890)"
export https_proxy="[http://127.0.0.1:7890](http://127.0.0.1:7890)"


curl -I [https://duckduckgo.com/](https://duckduckgo.com/)


4. 攻克硬核编译阶段的底层报错

在解决了网络与基础包问题后,脚本进入了漫长的 pip install 阶段,但这恰恰是最痛苦的环节。

坑一:Cryptography 模块编译“假死”与 Android API 变量缺失

由于 Android 环境没有预编译的 Python Wheel 包,安装 cryptography 时需要本地化调用 Rust 编译,终端只显示一行 Installing build dependencies ... | 并伴随着手机发热。

为了打破这种“不知道是不是死机”的黑盒状态,我通过 Ctrl+C 打断,并开启 -v 详细日志模式手动安装:

1
pip install cryptography==46.0.7 -v

输出结果(Maturin 构建崩溃):

1
2
3
💥 maturin failed
Caused by: Failed to determine Android API level. Please set the ANDROID_API_LEVEL environment variable.
Error running maturin: Command '['maturin', 'pep517', 'write-dist-info', ...] returned non-zero exit status 1.

原因剖析: 在 Android 上使用 maturin 编译 Rust 扩展库时,编译器必须知道具体的系统 API 级别,否则无法链接底层的 C 库。官方一键脚本遗漏了这一关键变量的注入。

解决方案: 向系统注册 API 级别变量,然后重试编译。

1
export ANDROID_API_LEVEL="$(getprop ro.build.version.sdk)"

坑二:Psutil 平台硬编码封杀

当终于熬过长达十几分钟的 Rust 编译后,安装脚本又在构建 psutil 模块时彻底阵亡。

输出结果(致命错误):

1
2
3
platform android is not supported
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.

原因剖析: psutil 的官方开发者在最新版本中硬编码封杀了 Android 平台。一旦检测到运行在安卓下,就会直接抛出该异常并罢工。此时,盲目拉取最新依赖的官方“一键安装脚本”已经彻底宣告破产。


5. 最终落地:摒弃一键脚本的手动完美方案

经过以上一连串的排雷,我得出一个结论:在 Termux 这种特殊环境下,必须放弃高度封装的一键脚本,采用完全透明的手动分步部署。

以下是最终整理出的一套百分百能跑通的纯净安装流程:

步骤一:准备系统环境与代码

1
2
3
4
5
6
7
8
9
10
11

export http_proxy="[http://127.0.0.1:7890](http://127.0.0.1:7890)"
export https_proxy="[http://127.0.0.1:7890](http://127.0.0.1:7890)"


pkg update && pkg upgrade -y
pkg install -y git python clang rust make pkg-config libffi openssl nodejs ripgrep ffmpeg ca-certificates


git clone [https://github.com/NousResearch/hermes-agent.git](https://github.com/NousResearch/hermes-agent.git)
cd hermes-agent

步骤二:构建受限的虚拟环境

这一步是整个过程的灵魂。我们必须注入 API 变量,并使用官方仓库中针对 Termux 专门编写的约束文件(constraints-termux.txt),以锁定那些未经安卓封杀的老版本依赖(如老版本的 psutil)。

1
2
3
4
5
6
7
8
9
10
11
12

python -m venv venv
source venv/bin/activate


export ANDROID_API_LEVEL="$(getprop ro.build.version.sdk)"


python -m pip install --upgrade pip setuptools wheel


pip install -e '.[termux]' -c constraints-termux.txt

步骤三:验证与运行

1
2

hermes setup

6. 总结与实践建议

  1. 一键脚本的适用边界curl | bash 这类脚本在标准 Linux 发行版上体验极佳,但在高度定制的移动端环境(如 Termux)中,往往会因为交互式提示、缺少预编译二进制包、甚至由于开发者恶意封杀平台而失效。掌控底层构建逻辑是移动端开发的必修课。
  2. 抵抗系统杀后台机制:在手机上成功跑起 Agent 后,最大的敌人变成了 Android 的电池优化机制。建议在 Termux 中执行 termux-wake-lock 开启 CPU 唤醒锁,并配合 tmux 工具将 Hermes 挂载在后台会话中运行,防止 UI 界面被清理导致进程意外中断。