DEV Community

Corey Alexander
Corey Alexander Subscriber

Posted on • Edited on • Originally published at coreyja.com

Setting up new Laptop and Upgrading to Homebrew 2

This post was originally published on coreyja.com

This blog post is gonna be a walk-through of setting up my new laptop, which led to this PR from my dotfiles repo. There were a few things I needed to update to get the laptop running. The biggest one was upgrading from Homebrew 1.x to Homebrew 2.0

Setting up the new machine

Overall I was really happy with how painless the migration to a new machine was, thanks in large part to Homebrew and my dotfiles repo. With these two I was able to install everything I needed and have most of my configuration already working without any additional work.

I didn't record the exact commands I ran but it was something like this

cd ~
git init .
git add remote origin https://github.com/coreyja/dotfiles.git
git fetch origin
git checkout --track origin/master
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew bundle
~~~{% endraw %}

What this does is checkout my {% raw %}`dotfiles`{% endraw %} repo in the home dir. This isn't how some people do their dotfiles, where they store the version controlled files somewhere else and copy or symlink then into their homedir. Instead I keep my actual home directory under version control, but have the {% raw %}`.gitignore` set up as a white-list, where I have to specifically add files to be tracked. This works really well for me since I don't have to maintain two different directories. I wrote a bit more about that [setup here.](blog/2018/01/06/dotfiles-december-2018.html)

My first {% raw %}`brew bundle`{% endraw %} didn't work, since there were some upgrades I needed to make! The rest of this post will be about the changes I had to make to get up and running! Overall I felt like I only had to make a few small changes and I was up and running really quickly!


## Homebrew 2

In February of this year, the Homebrew community [released Homebrew 2.0](https://brew.sh/2019/02/02/homebrew-2.0.0/) šŸŽ‰ šŸŽ‰

First I want to say thanks to the whole Homebrew community for all the work they do! Getting out 2.0 is an awesome milestone!

### Removal of Options

There were a few changes in Brew 2 that affected my dotfiles, and setup.

The first was the removal of options for all formulae in `Homebrew/homebrew-core`. This is the default tap and as such many a few options I was using were no longer supported. There were a few options I was using that I simply removed, and I don't think I was actively using them. This included the {% raw %}`--with-webp`{% endraw %} option for {% raw %}`imagemagick`{% endraw %} and {% raw %}`--with-iri`{% endraw %} for {% raw %}`wget`{% endraw %}.

However there was one class of options that I did still want to support! And that is the {% raw %}`--with-default-names`{% endraw %} option that I was using on a few GNU utils, including {% raw %}`coreutils`{% endraw %}, {% raw %}`grep`{% endraw %} and {% raw %}`sed`{% endraw %}. This option made it so I could use the Homebrew installed versions of these utilities without using them with their {% raw %}`g`{% endraw %} prefix. So for example I wanted to be able to use {% raw %}`sed`{% endraw %} not {% raw %}`gsed`{% endraw %} to use the GNU {% raw %}`sed`{% endraw %} tool.

However it is relatively painless to accomplish this! I did it by adding the follow code snippets to my {% raw %}`.bash_profile`{% endraw %}. These came directly from the {% raw %}`CAVEATS`{% endraw %} section of each of the Brew installs{% raw %}

~~~bash
# Add GnuCoreUtils to the Path
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
export MANPATH="/usr/local/opt/coreutils/libexec/gnubin:$MANPATH"
# Add grep to the Path
export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
export MANPATH="/usr/local/opt/grep/libexec/gnubin:$MANPATH"
# Add sed to the Path
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
export MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"
~~~{% endraw %}

This actually does one more thing besides just add these utilities to the PATH. It also sets the {% raw %}`MANPATH`{% endraw %} so that you can do {% raw %}`man sed`{% endraw %} and get the correct documentation for the GNU {% raw %}`sed`{% endraw %} tool

## Other Brewfile Changes

I also made a few additional changes to my Brewfile not related to the upgrade.

I removed a few things that had trouble installing and I didn't use anymore including `svg-term` and `heroku`.

I also removed `gpg-agent` since it is bundled with `gpg` now.

I added `go` and `rustup` since my setup depends on some go and Rust utilites. I've had these on my machine previously but missed adding them to my dotfiles. I also realized that some of the GUI tools I wanted could be installed via {% raw %}`cask`{% endraw %} so I added a few of those as well

## Added a base `.ruby-version` file

I was actually surprised I hadn't already done this when I setup the new laptop. But I wasn't keeping the {% raw %}`.ruby-version`{% endraw %} file in my homedir under {% raw %}`git`{% endraw %}, so I changed that by adding the latest currently available version of ruby as my default {% raw %}`.ruby-version`{% endraw %}. I will still have projects that depend on different versions of Ruby, and have their own {% raw %}`.ruby-version`{% endraw %} file. But this will give me a good default version, that is consistent between machines.

Enter fullscreen mode Exit fullscreen mode

Top comments (0)