Skip to content

Give SSH commands the user-level tool paths - #6632

Merged
dhh merged 2 commits into
quattrofrom
ssh-command-path
Aug 8, 2026
Merged

dhh merged 2 commits into
quattrofrom
ssh-command-path

Conversation

@dhh

@dhh dhh commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

herdr --remote bridges with ssh -T, so the remote server starts from a non-login, non-interactive shell. On Arch nothing user-configurable runs in that context — no /etc/profile, and bash isn't compiled with Debian's SSH_SOURCE_BASHRC patch — so the server sees the bare sshd PATH and can't find any mise-managed agent CLIs (claude, codex, …). The same failure hits any ssh host cmd remoting convention.

Three layers, outermost first:

  • PAM environment: install/config/ssh-command-path.sh (wired into install/config/all.sh) appends a PATH DEFAULT=...:@{HOME}/.local/share/mise/shims:@{HOME}/.local/bin line to /etc/security/pam_env.conf. pam_env.so sits in sshd's session stack and UsePAM yes is the Arch default, so plain SSH commands now inherit the user-level tool paths, expanded per-user from passwd. migrations/1786181929.sh applies the same line on existing installs. Both skip if a PATH line already exists there.
  • env-bootstrap: appends mise shims and ~/.local/bin (after system paths, so nothing shadows /usr/bin), which completes login shells (ssh -t, bash -lc) and the uwsm session. The redundant ~/.local/bin append in envs stays: dev-linked machines source the packaged env-bootstrap from .bashrc, so dropping it would regress them until the package ships.
  • default/bashrc: sources env-bootstrap above the interactive guard, for bash variants that read .bashrc non-interactively.

Verified: env -i HOME=... sh -c '. env-bootstrap; command -v claude herdr' resolves both from a bare PATH; pam_env append tested idempotent against a copy; ./test/shell (140 files) and ./test/cli pass, with dev-env-path-test.sh extended to cover the appends.

🤖 Generated with Claude Code

ssh host cmd runs neither a login nor an interactive shell, so on Arch it
gets the bare sshd PATH and can't find mise-managed tools like the agent
CLIs herdr scans for. Set PATH in the PAM environment (per-user via
@{HOME}), append the user-level dirs in env-bootstrap so login shells and
the uwsm session get them too, and source env-bootstrap before bashrc's
interactive guard for bash variants that read it non-interactively.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings August 8, 2026 10:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends user-level tool paths to SSH commands, login shells, and Omarchy sessions.

Changes:

  • Configures PAM paths for fresh and existing installations.
  • Extends and tests the shared environment bootstrap.
  • Sources the bootstrap for non-interactive Bash sessions.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/shell.d/dev-env-path-test.sh Tests path appending and deduplication.
migrations/1786181929.sh Adds PAM paths to existing systems.
install/config/ssh-command-path.sh Configures PAM paths during installation.
install/config/all.sh Runs the new installation step.
default/bashrc Bootstraps non-interactive shells.
default/bash/env-bootstrap Appends user-level executable paths.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread default/bash/env-bootstrap Resolved
Appending with a bare "$PATH:" prefix leaves a leading colon when PATH
is unset, which shells treat as the current directory.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings August 8, 2026 12:55
@dhh
dhh merged commit b925431 into quattro Aug 8, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

migrations/1786181929.sh:9

  • The added shell coverage only exercises env-bootstrap; this system-wide migration (and its fresh-install counterpart) is never run against a fixture. Because the skip-if-managed behavior and exact PAM syntax are the core of the change, add a configurable pam_env target and a shell test covering an absent file, an existing PATH entry, and a second idempotent run, following the migration-test pattern used elsewhere in test/shell.d/.
grep -qE '^PATH[[:space:]]' /etc/security/pam_env.conf && exit 0

sudo tee -a /etc/security/pam_env.conf >/dev/null <<'EOF'

nick1udwig pushed a commit to nick1udwig/omarchy that referenced this pull request Sep 9, 2026
* Give SSH commands the user-level tool paths

ssh host cmd runs neither a login nor an interactive shell, so on Arch it
gets the bare sshd PATH and can't find mise-managed tools like the agent
CLIs herdr scans for. Set PATH in the PAM environment (per-user via
@{HOME}), append the user-level dirs in env-bootstrap so login shells and
the uwsm session get them too, and source env-bootstrap before bashrc's
interactive guard for bash variants that read it non-interactively.

Co-Authored-By: Claude Fable 5 <[email protected]>

* Don't let an empty PATH turn into a cwd entry

Appending with a bare "$PATH:" prefix leaves a leading colon when PATH
is unset, which shells treat as the current directory.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants