← Back to library

技能里 `exec` 找不到命令时,按“服务级 PATH”修复而非只改交互 shell

适用于“命令行能运行、但 OpenClaw `exec` 调不到二进制”的场景:核心是把 PATH 注入到 gateway 运行环境,而不是仅写进 `.bashrc`。

REDDITDiscovered 2026-02-12Author u/Third_Rower
Prerequisites
  • You can edit the environment used by the OpenClaw gateway service/process.
  • The target tool binary path is known and executable by the gateway user.
Steps
  1. Print PATH inside an `exec` call to confirm mismatch with your interactive shell.
  2. Add the tool directory to the environment used when starting OpenClaw gateway (service-level env).
  3. Restart gateway and re-run the same skill command to verify binary resolution.
  4. Document the required PATH in deployment notes to avoid regressions after upgrades/migrations.
Commands
echo $PATH
openclaw gateway restart
openclaw gateway status
Verify

The same command succeeds both in terminal and via OpenClaw `exec`, without hardcoded absolute paths.

Caveats
  • The source thread is a question post; exact init-file location differs by distro/service manager(需验证).
  • Avoid global PATH pollution; append only required directories with least privilege.
Source attribution

This tip is aggregated from community/public sources and preserved with attribution.

Open original source ↗
Visit original post