Skip to content

Make all installation scripts idempotent #17

@slifty

Description

@slifty

Problem

Many installation scripts cannot be safely re-run, causing errors or inconsistent state when running bootstrap.sh multiple times.

Specific Issues

  1. zsh/install.sh reinstalls Oh My ZSH every time (will fail if already installed)
  2. python/install.sh:2 tries to create plugins directory without checking if it exists
  3. python/install.sh:3 creates symlink without checking if it already exists
  4. homebrew/preinstall.sh:16 appends to .zprofile every time (creating duplicates)
  5. macos/install.sh sets dock apps without checking current state

Impact

  • Can't safely re-run bootstrap after initial setup
  • Makes incremental updates/fixes difficult
  • Causes confusing error messages
  • May create duplicate configurations

Recommended Solution

Make all scripts idempotent by adding checks before operations:

# Example: Check before creating directory
if [ ! -d "$(pyenv root)/plugins" ]; then
  mkdir "$(pyenv root)/plugins"
fi

# Example: Check before creating symlink
if [ ! -L "$(pyenv root)/plugins/pyenv-install-latest" ]; then
  ln -s ~/.dotfiles/python/pyenv-install-latest "$(pyenv root)/plugins/pyenv-install-latest"
fi

# Example: Check if line already exists before appending
if ! grep -q "brew shellenv" "$HOME/.zprofile"; then
  echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> $HOME/.zprofile
fi

Success Criteria

  • bootstrap.sh can be run multiple times without errors
  • Scripts detect existing installations and skip redundant operations
  • Clear messaging about what's being skipped vs. installed

Priority

MEDIUM - Important for maintainability and user experience

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions