guard shell setup snippets against non-interactive logins - #1553
Open
ChrisJr404 wants to merge 1 commit into
Open
guard shell setup snippets against non-interactive logins#1553ChrisJr404 wants to merge 1 commit into
ChrisJr404 wants to merge 1 commit into
Conversation
The README setup snippets and the installer-appended ones for bash, zsh and fish run `fnm env` unconditionally. Non-interactive logins (notably KDE/SDDM running `fish --login -c '/bin/sh -c export -p'` to scrape env vars at session start) hit that snippet too, which generates a multishell directory and ends up baked into the systemd user environment. Every subsequent terminal then runs `fnm env` on top of that stale path, and `fnm use system` resolves to the old multishell instead of /usr/bin/node. Wrap the documented and installer-emitted invocations in an interactive check so the non-interactive path is a no-op: bash/zsh: [[ $- == *i* ]] && eval ... fish: status is-interactive; and fnm env ... | source The installer-side CI test now invokes the test shells with `-i` so the sourced profile still initializes fnm under the guard. Closes Schniz#1551 Signed-off-by: ChrisJr404 <chris@hacknow.com>
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.
Closes #1551.
Why
The setup snippets we publish (and the ones the installer appends to user dotfiles) run
fnm envunconditionally:On Linux with a systemd user session, the display manager spawns a non-interactive login shell at session start to scrape env vars. With Plasma/SDDM the call tree is:
After that, every interactive terminal inherits the stale
fnm_multishells/<dir>from the session env and adds its own on top. The visible symptom:fnm use systemresolves to the older session-level multishell instead of/usr/bin/node. Detailed repro andpstreecapture are in the linked issue.Fix
Wrap the documented invocations and the installer-appended snippets in an interactive-shell check, so non-interactive parents leave PATH untouched:
bash and zsh
fish
Same check is added inside the existing
if [ -d "$FNM_PATH" ]block in.ci/install.shfor bash, zsh and fish.PowerShell and the WinCMD/Cmder snippets are left alone since the issue is specific to Linux display-manager session-init behavior, and adding an untested PowerShell host-interactive check has more downside than upside here.
Testing
Verified each guard locally against an actual non-interactive vs interactive invocation:
bash -n,zsh -nandfish -nall parse the generated snippets cleanly..ci/test_installation_script.shnow runs the test shells with-i -cso the appended fnm block actually fires through the guard when sourcing the profile. Without that change the existing CI path (bash,zsh,fishall invoked as-c) would no-op the eval and thefnm install/fnm usesteps would fail to find node on PATH.A changeset (
patch) is included.