← Back to PRs

#15403: inject shell rc contents to none interactive shells BUG #9302

by devzer01 open 2026-02-13 11:41 View on GitHub →
gateway stale size: S
This fixes errors produced due to shell rc content not being loaded for none interactive shells. https://github.com/openclaw/openclaw/issues/15396 ex. System: [2026-02-13 18:25:53 GMT+7] Cron: ⚠️ 🛠️ Exec: cd ~/.openclaw/workspace && python - <<'PY' failed: zsh:1: command not found: python I don't believe creating a symlink to patch the underline issue is not the right solution. This approach will improve the usability of the product for a larger audience. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a `buildEnvDumpCommand()` function that generates shell-specific RC-sourcing commands before running `env -0` to dump the environment. Previously, both `loadShellEnvFallback` and `getShellPathFromLoginShell` ran `env -0` in a login shell (`-l`), which loads profile files (`.bash_profile`, `.zprofile`) but skips interactive RC files (`.bashrc`, `.zshrc`) where tools like pyenv/nvm/rbenv commonly set PATH. This caused "command not found" errors for tools configured in RC files when running in non-interactive contexts (e.g., cron jobs). The new function handles zsh, bash, fish, ksh variants, tcsh/csh, nushell, elvish, xonsh, and pwsh/powershell, with a POSIX-compatible fallback for unknown shells. Tests are comprehensive and cover all shell variants plus integration tests verifying the command is passed through to `exec`. - Adds `buildEnvDumpCommand()` with a `switch` on `path.basename(shell)` to map shells to their RC-sourcing commands - Replaces the hardcoded `"env -0"` string in both `loadShellEnvFallback` and `getShellPathFromLoginShell` with `buildEnvDumpCommand(shell)` - Adds thorough unit tests for all shell variants and integration tests that verify the full `exec` call arguments <h3>Confidence Score: 4/5</h3> - This PR is safe to merge — it adds well-guarded RC sourcing with error suppression across all shell types, and all commands fail gracefully via existing try/catch blocks. - Score of 4 reflects: solid implementation with appropriate error handling for each shell type, comprehensive test coverage, no critical logic bugs found. The only concern is that the default fallback sources `.bashrc`/`.zshrc` inside unknown shells (e.g., dash), which could partially execute bash-specific syntax — but this is a minor risk mitigated by `|| true` and the surrounding try/catch, and was already discussed in prior review threads. - No files require special attention — the implementation and tests are well-aligned. <sub>Last reviewed commit: 94a6de4</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs