Skip to content

Conversation

@latchloop
Copy link

@latchloop latchloop bot commented Oct 7, 2025

Dotfiles Robustness & Idempotency Improvements

This PR significantly improves the robustness, safety, and idempotency of the dotfiles bootstrap process and related setup scripts. The changes address common pitfalls in dotfile management and onboarding, making setup faster, safer, and more reliable for both fresh installs and repeated runs.

Closes https://app.latchloop.com/tasks/0e9d9459-48c6-436a-aacd-a71fbe0fcf8d


Key Changes

init_dotfiles.sh

  • Safety & Idempotency
    • Added set -euo pipefail for strict error handling.
    • Resolves dotfiles directory via $HOME/.dotfiles.
    • Uses ln -sfn to safely overwrite existing symlinks.
    • Backs up any real files (not symlinks) before linking, with timestamped .bak suffix.
    • Removes unnecessary pushd/popd; script can run from any directory.
  • Submodule Handling
    • Uses git submodule update --init --recursive for robust submodule setup.

osx/setup.rb

  • Sudo Handling
    • Prompts for sudo once at the start and keeps credentials alive throughout execution.
  • Idempotency & Path Robustness
    • Checks for existence before cloning dotfiles, installing plugins, or adding entries to /etc/shells.
    • Handles both Apple Silicon and Intel Homebrew paths for shell and Brewfile.
  • Package Installation
    • Homebrew install is non-interactive (NONINTERACTIVE=1).
    • Ensures brew is in PATH before running brew bundle.
    • Uses python3 -m pip install ... instead of pip3.
    • Uses asdf exec gem install ... for Ruby gems.
    • Checks for asdf plugin existence before adding.
    • Sets global Ruby version after install.
  • Vim & Zim Setup
    • Auto-installs vim-plug if missing.
    • Runs zimfw install after downloading zimfw.zsh.
  • SSH Keys
    • Checks for SSH key presence and prompts to generate if missing.
  • Fonts & Themes
    • Automates Monaco font install (opens font file).
    • Prints manual steps for iTerm2 color schemes and Powerline fonts.
  • Phoenix/Elixir
    • Ensures Elixir/Erlang are installed before running mix commands.
    • Uses --force for non-interactive hex and Phoenix installer.
  • General
    • Minimizes interactive prompts; collects manual steps as notes.

Testing & Verification

To verify these changes:

  1. Fresh Install
    • On a clean macOS user account, run osx/setup.rb.
    • Confirm that:
      • Dotfiles are symlinked, with backups of any pre-existing files.
      • No duplicate entries are added to /etc/shells.
      • Homebrew, asdf, and plugins are installed correctly.
      • Vim-plug and Zim are auto-installed.
      • SSH key presence is checked and prompted if missing.
      • Monaco font is opened for installation.
      • Manual steps are printed at the end.
  2. Repeat Runs
    • Re-run the setup scripts; confirm no errors, no duplicate entries, and no destructive overwrites.
    • Confirm .bak files are only created if real files exist.
  3. CI/Lint
    • Optionally run ShellCheck on init_dotfiles.sh for linting.
    • Run brew bundle check to validate Brewfile.

Additional Notes

  • These changes

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