Search code examples
dotfiles

Attempting to install homebrew through dotfile install config


I'm using the dotbot package to easily control how my files are setup on fresh install of macos. After running the my install.conf.yml file the following command does not run successfully and I'm asking for suggestions as to what could be the problem. I have included the error message below to try and give some clarification as to what is happening. I wish there was more information that is returned to the user when a command does not successfully run as to why it didn't but it doesn't.

- shell:
    - if: '[$(which brew) 2>&1 > /dev/null]'
    - description: install homebrew
      command: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

An error was encountered while executing action shell. Action shell not handled


Solution

  • I got it working by creating a new .zsh file, making it an executable, and running the homebrew install command from within the .zsh file.

    You could make the .zsh executable by running chmod +x <name-of-file>.zsh

    Then the dotbot install.conf.yaml file could run the zsh file.

    I also had to make sure the options from the dotbot config file allowed stdin and stdout so that I could put in my password and press return when the homebrew installation asks for it.

    If you want more error output just in case the script fails you could also set the stderr option. This way it outputs the error of the program itself instead of the custom dotbot error

    install.conf.yaml:

    ...
    - shell:
      -
        command: ./scripts/setup_homebrew.zsh
        stdin: true
        stdout: true
        stderr: true
    ...
    

    setup_homebrew.zsh

    #!/usr/bin/env zsh
    
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"