Skip to content

fix(terminal): fix iTerm2 prefs chown path and username variable#79

Merged
smartwatermelon merged 1 commit intomainfrom
claude/fix-iterm2-prefs-chown-1773109791
Mar 10, 2026
Merged

fix(terminal): fix iTerm2 prefs chown path and username variable#79
smartwatermelon merged 1 commit intomainfrom
claude/fix-iterm2-prefs-chown-1773109791

Conversation

@smartwatermelon
Copy link
Copy Markdown
Owner

Summary

Two bugs in copy_iterm2_preferences_to_user() in scripts/server/setup-terminal-profiles.sh that caused first-boot.sh to crash during iTerm2 preferences setup:

  • Double-path bug (line 338): ${operator_library_prefs_dir}/${preferences_file} — when preferences_file is an absolute path (as it is when copied from the airdrop package), this constructs a malformed double-path like /Users/operator/Library/Preferences//Users/andrewrich/Downloads/tilsit-setup/config/com.googlecode.iterm2.plist. The chown call fails with "No such file or directory," which causes the surrounding if block to take the else branch, collect_error fires, and first-boot.sh exits with a non-zero status. Fix: $(basename "${preferences_file}") extracts just the filename.

  • Missing $ on variable (lines 339/341/343): "{username}" is a literal string — bash does not expand it. Every sudo -iu "{username}" call silently runs as an undefined user. Fix: "${username}".

Test plan

  • shellcheck passes with zero warnings/errors
  • Run first-boot.sh on TILSIT (or a clean test) with USE_ITERM2=true and confirm iTerm2 preferences are copied without error
  • Confirm chown target path is /Users/operator/Library/Preferences/com.googlecode.iterm2.plist (not a double-path)

🤖 Generated with Claude Code

Two bugs in copy_iterm2_preferences_to_user():

1. Line 338: `${operator_library_prefs_dir}/${preferences_file}` built
   a double-path when preferences_file is an absolute path (e.g.
   /Users/foo/Downloads/.../com.googlecode.iterm2.plist), causing
   chown to fail with "No such file or directory" and crashing
   first-boot.sh. Fix: use $(basename "${preferences_file}") to extract
   just the filename before appending to the target directory.

2. Lines 339/341/343: `"{username}"` missing $ — bash expanded it as
   the literal string "{username}" rather than the variable value,
   so sudo -iu ran as an undefined user. Fix: "${username}".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@smartwatermelon smartwatermelon merged commit f720e70 into main Mar 10, 2026
20 checks passed
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.

1 participant