标题: 在鸿蒙PC上安装原版DeepSeek Harness / DSH(让koffi可用,解决硬连接和权限问题)
时间: 4小时前发布,2小时前修改
安装 Harmonybrew:https://harmonybrew.atomgit.com/
用uname-is-linux 把系统伪装成Linux,避免 koffi 安装报错:
brew install -y ohos-sdk devel-base llvm-gcc-compat cmake uname-is-linux
安装完成后请重新打开终端,执行以下命令验证效果:
export LD_PRELOAD=$HOME/.harmonybrew/opt/uname-is-linux/lib/libuname.so
uname -a
应该会显示Linux而非HarmonyOS。
brew install python3 node
npm config set prefix "$HOME/.npm-global"
export LD_PRELOAD=$HOME/.harmonybrew/opt/uname-is-linux/lib/libuname.so
npm install -g @deepseek-ai/dsh --verbose
如果还是在安装koffi的时候报错,请重新打开终端让uname伪装生效。
ohos-sdk附带的binary-sign-tool命令对koffi库进行签名,让koffi能正常加载(不签名会报Permission denied错误):f="$HOME/.npm-global/lib/node_modules/@deepseek-ai/dsh/node_modules/koffi/build/koffi/openharmony_arm64/koffi.node"; binary-sign-tool sign -inFile "$f" -outFile "$f" -selfSign 1
完整的签名工具教程(包括另一个可以给claude二进制签名的第三方签名工具):
https://hu60.cn/q.php/bbs.topic.107186.html#nav
sharp库的问题:cd "$HOME/.npm-global/lib/node_modules/@deepseek-ai/dsh"
npm install --no-save --no-package-lock --no-audit --no-fund @img/[email protected]
node启动时缺少--expose-internals参数的问题:sed -i 's@^#!/usr/bin/env node$@#!'"$HOME"'/.harmonybrew/bin/node --expose-internals@' "$HOME/.npm-global/lib/node_modules/@deepseek-ai/dsh/lib/bin.js"
这条命令是把 $HOME/.npm-global/lib/node_modules/@deepseek-ai/dsh/lib/bin.js 的第一行改成 #!/storage/Users/currentUser/.harmonybrew/bin/node --expose-internals
本轮运行失败EACCES: permission denied, link '/storage/Users/currentUser/.dsh/sessions/--storage-Users-currentUser-work-wine-WineHua--/session-207ab6ad-2f89-445f-8e60-c11b72a2de56/session.jsonl.zstd.55acf2760149.tmp' -> '/storage/Users/currentUser/.dsh/sessions/--storage-Users-currentUser-work-wine-WineHua--/session-207ab6ad-2f89-445f-8e60-c11b72a2de56/session.jsonl.zstd'
改为在硬连接失败后直接重命名(通过nodejs脚本给源代码打补丁,把下面的代码一次性复制到终端粘贴执行即可):
FILE="$HOME/.npm-global/lib/node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/lib/index.js"
cp "$FILE" "$FILE.bak"
node - "$FILE" <<'NODE'
const fs = require("fs");
const f = process.argv[2];
let s = fs.readFileSync(f, "utf8");
// 1) import 增加 rename
const OLD_IMPORT = 'import { link, mkdir, mkdtemp, open, readFile, readdir, realpath, rm, stat, truncate } from "node:fs/promises";';
const NEW_IMPORT = 'import { link, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, stat, truncate } from "node:fs/promises";';
if (!s.includes(OLD_IMPORT)) { console.error("[1/2] import 行未找到(可能已打过补丁)"); process.exit(0); }
s = s.replace(OLD_IMPORT, NEW_IMPORT);
// 2) link → link 失败时回退 rename(HarmonyOS 禁止硬链接 EACCES/EPERM)
const OLD_LINK = "await link(tmp, finalPath);";
if (!s.includes(OLD_LINK)) { console.error("[2/2] link 语句未找到(可能已打过补丁)"); process.exit(0); }
const NEW_LINK = 'try { await link(tmp, finalPath); } catch (error) { if (error.code !== "EACCES" && error.code !== "EPERM") throw error; await rename(tmp, finalPath); }';
s = s.split(OLD_LINK).join(NEW_LINK);
fs.writeFileSync(f, s);
console.log("patched:", f);
NODE
Error: dsh: plugin tree failed to load: failed to apply loader entry include (cordis:include): failed to apply loader entry credentials (@deepseek-ai/dsh-credentials-local): credentials-local: /storage/Users/currentUser/.dsh/.credentials.yaml is readable beyond its owner (mode 660); run "chmod 600 /storage/Users/currentUser/.dsh/.credentials.yaml" before starting again
Error: credentials-local: /storage/Users/currentUser/.dsh/.credentials.yaml is readable beyond its owner (mode 660); run "chmod 600 /storage/Users/currentUser/.dsh/.credentials.yaml" before starting again
rm -rf ~/.dsh
mkdir /data/storage/el2/base/files/dsh
ln -s /data/storage/el2/base/files/dsh ~/.dsh
/data/storage/el2/base/files是正常的f2fs文件系统,权限可以正常设为660,不过还是不支持硬连接。
ln -s ~/.npm-global/bin/dsh ~/.harmonybrew/bin
dsh web
然后就可以访问 http://127.0.0.1:3080 进行使用了。
安装 bash 即可:
brew install bash
海泰浏览器(左)的Origin头不含端口,会导致API返回403错误,目前暂时无法解决。换成海泰极速浏览器(右)就没有这个问题了。
在海泰浏览器里选择“重置设置”也可以解决该问题。
『回复列表(0|显示机器人聊天)』