Repository navigation
fix starting zsh profile #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the zsh startup sequence violation.
The current implementation sources
.zshenvand.zloginfrom within.zshrc, which violates zsh's expected startup order and can cause initialization issues.Expected zsh startup sequence:
.zshenv→.zprofile→.zshrc→.zloginCurrent sequence with wrappers:
.zprofile→ sources user's.zprofile.zshrc→ sources user's.zshenv❌ (too late),.zshrc✓,.zlogin❌ (too early)Impact:
.zshenvare unavailable when their.zprofileruns (breaks PATH setup dependencies).zloginrun before.zshrccompletes (breaks timing assumptions)Recommended fix:
Create separate wrapper files for each startup file to maintain the correct sequence:
function createZshWrapper(): void { + // Create .zshenv wrapper (runs first, always) + const zshenvPath = path.join(ZSH_DIR, ".zshenv"); + const zshenvScript = `# Superset zsh environment wrapper +# Restore original ZDOTDIR for nested shells +export ZDOTDIR="\${SUPERSET_ORIG_ZDOTDIR:-$HOME}" + +# Source user's .zshenv if it exists +[[ -f "$ZDOTDIR/.zshenv" ]] && source "$ZDOTDIR/.zshenv" +`; + fs.writeFileSync(zshenvPath, zshenvScript, { mode: 0o644 }); + // Create .zprofile to source user's .zprofile (runs for login shells before .zshrc) // This is critical - without it, brew/nvm PATH setup in ~/.zprofile is skipped const zprofilePath = path.join(ZSH_DIR, ".zprofile"); const zprofileScript = `# Superset zsh profile wrapper -_superset_home="\${SUPERSET_ORIG_ZDOTDIR:-$HOME}" -[[ -f "$_superset_home/.zprofile" ]] && source "$_superset_home/.zprofile" +[[ -f "$ZDOTDIR/.zprofile" ]] && source "$ZDOTDIR/.zprofile" `; fs.writeFileSync(zprofilePath, zprofileScript, { mode: 0o644 }); // Create .zshrc to source user's .zshrc then prepend our bin const zshrcPath = path.join(ZSH_DIR, ".zshrc"); const zshrcScript = `# Superset zsh initialization wrapper -# This file intercepts zsh startup to ensure ~/.superset/bin is in PATH - -# Restore original ZDOTDIR for any nested shells -export ZDOTDIR="\${SUPERSET_ORIG_ZDOTDIR:-$HOME}" - -ORIG_ZDOTDIR="$ZDOTDIR" - -# Source the same user-level startup files zsh normally would -if [[ -f "$ORIG_ZDOTDIR/.zshenv" ]]; then - source "$ORIG_ZDOTDIR/.zshenv" -fi - # Source user's real zshrc if it exists -if [[ -f "$ORIG_ZDOTDIR/.zshrc" ]]; then - source "$ORIG_ZDOTDIR/.zshrc" -fi - -# Finish login shell sequence -if [[ -o login && -f "$ORIG_ZDOTDIR/.zlogin" ]]; then - source "$ORIG_ZDOTDIR/.zlogin" -fi - -# Prepend superset bin to PATH (after user's rc has run) -export PATH="$HOME/${SUPERSET_DIR_NAME}/bin:$PATH" +[[ -f "$ZDOTDIR/.zshrc" ]] && source "$ZDOTDIR/.zshrc" `; fs.writeFileSync(zshrcPath, zshrcScript, { mode: 0o644 }); + + // Create .zlogin wrapper (runs last for login shells) + const zloginPath = path.join(ZSH_DIR, ".zlogin"); + const zloginScript = `# Superset zsh login wrapper +# Source user's .zlogin if it exists +[[ -f "$ZDOTDIR/.zlogin" ]] && source "$ZDOTDIR/.zlogin" + +# Prepend superset bin to PATH (runs at the very end) +export PATH="$HOME/${SUPERSET_DIR_NAME}/bin:$PATH" +`; + fs.writeFileSync(zloginPath, zloginScript, { mode: 0o644 }); + console.log("[agent-setup] Created zsh wrapper"); }Note: By setting
ZDOTDIRonce in.zshenvand using$ZDOTDIRin subsequent wrappers, nested shells automatically use the originalZDOTDIRwithout needing to re-export it in every file.🤖 Prompt for AI Agents