Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@brosner
Last active April 26, 2020 11:32
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save brosner/8b9406a6da286efc4e18 to your computer and use it in GitHub Desktop.
Save brosner/8b9406a6da286efc4e18 to your computer and use it in GitHub Desktop.
My development environment setup

Prepare by switching out of bash from Homebrew:

chsh -s /bin/zsh

To clean my system and reinstall Homebrew:

rm -rf ~/.local && mkdir ~/.local
rm -rf ~/Library/Caches/pip
rm -rf ~/.pyenv
rm -rf ~/.yarn
rm -rf ~/.config/yarn
rm -rf ~/.nvm && mkdir ~/.nvm
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then I run brew doctor and resolve any issues that it finds.

On fresh OS installs, I usually need to run:

xcode-select --install

Once all is good, I install some base packages:

brew install git zsh go hub yarn nvm direnv
brew tap homebrew/command-not-found
brew install pyenv

There is no technical reason for the grouping. I like the logical grouping.

Get Homebrew bash setup by ensuring /usr/local/bin/zsh is in /etc/shells then run:

chsh -s /usr/local/bin/zsh

Python:

pyenv install 3.7.0 && pyenv install 2.7.15
pyenv global 3.7.0 2.7.15

[.bashrc] To initialize pyenv:

if which pyenv > /dev/null; then
    eval "$(pyenv init -)";
fi

At this point I will usually kill Terminal.app and start it up to ensure my shell environment is clean and using things from my new /usr/local install.

I use pipsi to handle system-level Python packages that want to expose commands for me:

pip install pipsi
pipsi install httpie
pipsi install slack-cli
pipsi install pipenv
pipsi install coreapi-cli

Make sure to add ~/.local/bin to your PATH.

minikube:

curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.22.1/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

ec:

(export dest=$HOME/.local/bin ; curl -s https://storage.googleapis.com/ec-cli/ec-v0.8.0_darwin-amd64 > $dest/ec && chmod +x $dest/ec)

Finally, here is a running list of software I install on my machine:

brew install redis watch caddy ack awscli coreutils curl dnsmasq elasticsearch gnu-tar gpg-agent hugo ipfs jq mercurial mongodb moreutils netcat pinentry pv socat wget xz neovim

Update pipenv:

~/.local/venvs/pipenv/bin/pip install --upgrade pipenv

Extra

~/.config/direnv/direnvrc:

use_nvm() {
    local node_version=$1
    nvm_sh=~/.nvm/nvm.sh
    if [[ -e $nvm_sh ]]; then
        source $nvm_sh
        nvm use $node_version
    fi
}

use_pyenv() {
    unset PYENV_VERSION
    # because each python version is prepended to the PATH, add them in reverse order
    for ((j = $#; j >= 1; j--)); do
        local python_version=${!j}
        local pyenv_python=$(pyenv root)/versions/${python_version}/bin/python
        if [[ ! -x "$pyenv_python" ]]; then
        log_error "Error: $pyenv_python can't be executed."
        return 1
        fi
        unset PYTHONHOME
        local ve=$($pyenv_python -c "import pkgutil; print('venv' if pkgutil.find_loader('venv') else ('virtualenv' if pkgutil.find_loader('virtualenv') else ''))")
        case $ve in
        "venv")
            VIRTUAL_ENV=$(direnv_layout_dir)/python-$python_version
            export VIRTUAL_ENV
            if [[ ! -d $VIRTUAL_ENV ]]; then
            $pyenv_python -m venv "$VIRTUAL_ENV"
            fi
            PATH_add "$VIRTUAL_ENV"/bin
            ;;
        "virtualenv")
            layout_python "$pyenv_python"
            ;;
        *)
            log_error "Error: neither venv nor virtualenv are available to ${pyenv_python}."
            return 1
            ;;
        esac
        # e.g. Given "use pyenv 3.6.9 2.7.16", PYENV_VERSION becomes "3.6.9:2.7.16"
        [[ -z "$PYENV_VERSION" ]] && PYENV_VERSION=$python_version || PYENV_VERSION="${python_version}:$PYENV_VERSION"
    done
    export PYENV_VERSION
}
@paltman
Copy link

paltman commented Oct 20, 2014

Thanks, @brosner. This was very helpful. Some notes and links about my setup that leans heavily on this is at: https://thoughtstreams.io/paltman/setting-up-new-dev-environment-on-yosemite/

@tardate
Copy link

tardate commented Nov 5, 2014

@brosner, thanks for sharing the notes. I'm curious how you got elasticsearch installed without noting any issues like elastic/elasticsearch#6440 Did you somehow end up with Java 7 installed instead of 8?

I'm trying to decide what to do next to resolve a jdk/elasticsearch showdown:

$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

$ brew install elasticsearch
elasticsearch: Java 1.7 is required to install this formula.
You can install Java from:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Make sure you install both the JRE and JDK.
Error: An unsatisfied requirement failed this build.

Postscript: doh, just realised you didn't specifically say this setup script was for Yosemite, so that may be why you didn't have any issues with elasticsearch.

On the elasticsearch front, seems no big deal. elasticsearch 1.4 runs fine with java 8 & 10.10. It's just that the homebrew elasticsearch formula still needs updating to 1.4.

@brosner
Copy link
Author

brosner commented Nov 17, 2014

@tardate this script was built on Yosemite. I did not notice any issues with installing it. Since I had done this a while ago, I am afraid I can't provide too many details. Thanks for pointing out the bug report. I'll keep this in mind if I redo things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment