Give SSH commands the user-level tool paths (#6632)
* 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 <noreply@anthropic.com>
* 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 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
ab367b9477
commit
b925431025
@@ -10,6 +10,7 @@ run_bootstrap() {
|
||||
local home="$3"
|
||||
local path_value="$4"
|
||||
|
||||
shell_bin=$(command -v "$shell_bin")
|
||||
HOME="$home" PATH="$path_value" "$shell_bin" -c '
|
||||
. "$1"
|
||||
printf "%s\n%s\n" "$OMARCHY_PATH" "$PATH"
|
||||
@@ -53,6 +54,9 @@ default_path=${default_result[1]}
|
||||
[[ ${default_result[0]} == /usr/share/omarchy ]] || fail "env-bootstrap resolves default OMARCHY_PATH" "actual: ${default_result[0]}"
|
||||
pass "env-bootstrap resolves default OMARCHY_PATH"
|
||||
assert_path_present "$default_path" "$tmpdir/unrelated/bin" "env-bootstrap preserves PATH entries in default mode"
|
||||
assert_path_present "$default_path" "$home/.local/share/mise/shims" "env-bootstrap appends mise shims"
|
||||
assert_path_present "$default_path" "$home/.local/bin" "env-bootstrap appends ~/.local/bin"
|
||||
assert_path_first "$default_path" "$tmpdir/unrelated/bin" "env-bootstrap appends user-level paths after existing entries"
|
||||
|
||||
printf 'export OMARCHY_PATH="%s"\n' "$tmpdir/active" >"$tmpdir/omarchy.conf"
|
||||
mapfile -t linked_result < <(run_bootstrap bash "$bootstrap" "$home" "$tmpdir/unrelated/bin:/usr/bin")
|
||||
@@ -63,10 +67,16 @@ pass "env-bootstrap resolves linked OMARCHY_PATH"
|
||||
assert_path_first "$linked_path" "$tmpdir/active/bin" "env-bootstrap prepends active checkout bin in linked mode"
|
||||
assert_path_present "$linked_path" "$tmpdir/unrelated/bin" "env-bootstrap preserves unrelated PATH entries in linked mode"
|
||||
|
||||
mapfile -t linked_duplicate_result < <(run_bootstrap bash "$bootstrap" "$home" "$tmpdir/active/bin:/usr/bin")
|
||||
mapfile -t linked_duplicate_result < <(run_bootstrap bash "$bootstrap" "$home" "$tmpdir/active/bin:/usr/bin:$home/.local/share/mise/shims:$home/.local/bin")
|
||||
linked_duplicate_path=${linked_duplicate_result[1]}
|
||||
[[ $linked_duplicate_path == "$tmpdir/active/bin:/usr/bin" ]] || fail "env-bootstrap does not duplicate active checkout bin" "actual PATH: $linked_duplicate_path"
|
||||
pass "env-bootstrap does not duplicate active checkout bin"
|
||||
[[ $linked_duplicate_path == "$tmpdir/active/bin:/usr/bin:$home/.local/share/mise/shims:$home/.local/bin" ]] || fail "env-bootstrap does not duplicate PATH entries" "actual PATH: $linked_duplicate_path"
|
||||
pass "env-bootstrap does not duplicate PATH entries"
|
||||
|
||||
# An empty PATH must not produce empty entries (a bare ":" means the cwd)
|
||||
mapfile -t empty_path_result < <(run_bootstrap bash "$bootstrap" "$home" "")
|
||||
empty_path=${empty_path_result[1]}
|
||||
[[ $empty_path == "$tmpdir/active/bin:$home/.local/share/mise/shims:$home/.local/bin" ]] || fail "env-bootstrap builds a clean PATH from an empty one" "actual PATH: $empty_path"
|
||||
pass "env-bootstrap builds a clean PATH from an empty one"
|
||||
|
||||
if command -v zsh >/dev/null 2>&1; then
|
||||
mapfile -t zsh_result < <(run_bootstrap zsh "$bootstrap" "$home" "$tmpdir/unrelated/bin:/usr/bin")
|
||||
|
||||
Reference in New Issue
Block a user