fix(shellexec): avoid false Snap detection and empty XDG_* vars#3402
fix(shellexec): avoid false Snap detection and empty XDG_* vars#3402Jason-Shen2 wants to merge 1 commit into
Conversation
…kip empty XDG values - Use SNAP_NAME == 'waveterm' instead of checking for any inherited SNAP variable, so child Snap processes do not trigger the XDG correction logic. - Remove empty values from varsToReplace before passing to UpdateCmdEnv so XDG_*_HOME variables are not explicitly set to empty strings. Previously an empty value would either unset the variable or set it to '' (depending on prior presence), breaking tools that rely on XDG spec defaults. Fixes wavetermdev#3336
|
zhenxing.shen seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughIn Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@CLAassistant check |
Summary
This fixes #3336 with two tightly-scoped changes in
pkg/shellexec/shellexec.go:1. Narrow the Snap detection guard
The previous check
os.Getenv("SNAP") != ""fires for any process that inherits $SNAP from a parent — including when Wave is launched from inside a Snap-installed terminal/CLI (e.g. the user snaps Alacritty or nvim and launches Wave from there). In that case Wave itself is not running as a Snap, but the code still wipes the XDG variables and tries to repopulate them from PAM.Changed the guard to:
SNAP_NAMEis set by Snapd to the declared snap name for the running snap only; inherited $SNAP from a parent process does not carry the parent'sSNAP_NAMEacross exec when the child is not a snap. This matches the documented Snap environment-variable conventions and ensures the correction only runs when Wave itself is the Snap.2. Do not explicitly set XDG vars to empty strings
After fetching PAM env vars, any XDG key not present in PAM was left as
""invarsToReplace, and was then passed toshellutil.UpdateCmdEnv. Depending on whether the key already existed in the command env, this either unset the variable or set it to the empty string, both of which break applications that rely on XDG Base Directory spec defaults (e.g.XDG_RUNTIME_DIRbeing empty caused the reported zsh-autosuggestions panic in uv/pipx-installed tools).Added a filter that drops keys still holding empty values before calling
UpdateCmdEnv. When a key is absent from the map, the child inherits the parent value (or uses spec defaults / shell rc files), which is the correct behavior on non-Snap systems and on Snaps where PAM didn't export that particular variable.Verification
go vet ./pkg/shellexec/passes.SNAPset butSNAP_NAME != waveterm, the Snap-correction block is no longer entered.SNAP_NAME=wavetermand a partial PAM env, missing keys are omitted fromvarsToReplacerather than set to"".Fixes #3336