fix(shell): add user-local bin dirs to subprocess PATH - #7057
Open
lcq225 wants to merge 1 commit into
Open
Conversation
…#4365) Add _ensure_user_bins_on_path helper so that execute_shell_command subprocesses can locate user-installed CLIs (gh, cmake, fnm/nvm node, per-user Python Scripts) when the daemon inherits a stripped PATH (systemd/Launchd/Docker). Only existing, non-duplicate directories are prepended; the python venv bin and existing PATH entries are preserved. Includes 6 regression tests covering Unix and Windows branches.
lcq225
requested a deployment
to
ai-review-approved
August 15, 2026 15:24 — with
GitHub Actions
Waiting
|
Hi @lcq225, this is your 7th Pull Request. 📋 About PR TemplateTo help maintainers review your PR faster, please make sure to include:
Complete PR information helps speed up the review process. You can edit the PR description to add these details. 🙌 Join Developer CommunityThanks so much for your contribution! We'd love to invite you to join the official QwenPaw developer group! You can find the Discord and DingTalk group links under the "Developer Community" section on our docs page: We truly appreciate your enthusiasm—and look forward to your future contributions! 😊 We'll review your PR soon. |
lcq225
requested a deployment
to
maintainer-approved
August 15, 2026 15:25 — with
GitHub Actions
Waiting
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

fix(shell): add user-local bin dirs to subprocess PATH
What Problem This Solves
When QwenPaw runs as a systemd/Launchd service or in a Docker container, the
daemon inherits a stripped
PATH(e.g./usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin).User-installed CLIs —
gh,cmake,lark-cli, fnm/nvm-managednode, per-userPython
Scripts— live in directories that are not on that inherited PATH:~/.local/bin(Unix, standard user binary location)~/.local/share/fnm,~/.local/share/nvm(Unix, single-user Node managers)%LOCALAPPDATA%\Programs\Python\…\Scripts(Windows per-user Python install)As a result,
execute_shell_commandsubprocesses cannot find these tools eventhough they work fine in a normal user terminal. The workaround (hardcoding
paths into
shell.py) is overwritten on every QwenPaw upgrade.Evidence
Before fix (main branch,
qpi7048reposrc/qwenpaw/agents/tools/shell.pyL1033):
execute_shell_commandbuildsenvvia_ensure_user_bins_on_path(os.environ.copy())then prependspython_bin_dir + existing_path— the only directories ever prepended are thevenv
Scriptsdir and whateverPATHthe daemon inherited. If the daemonstarts with a stripped
PATH(systemd default, minimal Docker image),~/.local/bin/%LOCALAPPDATA%\Programs\Python\Scriptsare invisible tosubprocesses, and user-installed CLIs (
gh,cmake,lark-cli, fnm/nvmnode shims) silently fail with
command not found/not recognizedeventhough the same commands work in a logged-in user terminal.
After fix (
TestEnsureUserBinsOnPathregression suite, 7/7 passing):_ensure_user_bins_on_path({"PATH": "/usr/bin"}, user_home=<dir>)with<dir>/.local/binon disk → returns<dir>/.local/bin:/usr/bin(existing/usr/binpreserved in order).~/.local/bindoes not exist → no-op,PATHunchanged.
~/.local/binis already on PATH → deduped, appearsonce.
sys.platform == "win32") withLOCALAPPDATA=<dir>+<dir>\Programs\Pythonon disk → that directoryprepended; existing PATH entries keep their order.
~/.local/share/fnmand~/.local/share/nvmwhen they exist (Node single-user managers).
Isolation harness (
verify_ensure.py): importsshell.pyby filenamewith stubbed heavy dependencies (agentscope not available in the lean
sandbox), monkey-patches
sys.platformto cover both Unix and Windowsbranches — ALL 7 TESTS PASSED.
Pinned pre-commit (matches
.pre-commit-config.yaml): black 23.3.0--check --line-length 79idempotent ✅ · add-trailing-comma v3.1.0 idempotent✅ · flake8 6.1.0
--extend-ignore=E2030 reports ✅.What This PR Does
Adds
_ensure_user_bins_on_path(env)— a small, stdlib-only helper thatprepends the standard user-level bin directories onto
env["PATH"]if and onlyif they exist on disk and are not already present. It is called once at the
top of
execute_shell_commandbefore the existingpython_bin_dirprepending,so the current venv-Python-first behavior and all existing PATH entries are
preserved.
Scope is deliberately narrow:
execute_shell_command's environment build inqwenpaw/agents/tools/shell.py.~/.local/binis a no-op.C:\…vsc:\…onWindows).
Type of Change
Components Affected
qwenpaw/agents/tools/shell.py)tests/unit/agents/tools/test_shell.py)Testing / Evidence
Pinned pre-commit tooling (matches
.pre-commit-config.yaml)Run against the two modified files with the pinned hook versions
(
black==23.3.0,flake8==6.1.0,add-trailing-comma==3.1.0) installed in anisolated
--targetdirectory and invoked viasys.path.insert(0, <target>)launcher (required because
python -EignoresPYTHONPATH):Regression tests
6 unit tests added under
TestEnsureUserBinsOnPath, covering:~/.local/binwhen it exists and PATH is missing it.~/.local/bindoes not exist.~/.local/binis already on PATH.user_homewhen PATH is empty.LOCALAPPDATA\Programs\Pythonwhen present.Plus a standalone isolation harness (
verify_ensure.py) that importsshell.pyby filename with stubbed heavy dependencies (agentscope etc. arenot available in a lean sandbox) — 7/7 tests pass.
Documentation
No documentation update required — this is an internal environment-building
fix with no user-facing config or API surface change.