How to set up a Mac OS-X development environment

Published: 2015-07-18

By: MJ Rossetti


This document describes the process of configuring a new Mac OS-X development environment from scratch.

Last updated: February 2018.

System Set-up

System Users

In System Preferences > Users and Groups, create a new admin user. Restart your computer and login as the new user. Delete the old user and any corresponding home folders.

System Preferences


In System Preferences > Security and Privacy > FileVault, turn FileVault ON. Take a screenshot of the recovery code. Restart the computer when prompted. Monitor progress for the next 20 minutes.

Keyboard Settings

In System Preferences > Keyboard:

  • Repeat: fastest
  • Delay until repeat: shortest
  • Shortcuts:
    • Move left a space: option + left arrow
    • Move right a space: option + right arrow

Spaces and Hot Corners

In System Preferences > Mission Control:

  • Do not auto-arrange.
  • Hot Corners:
    • TL: Mission Control
    • TR: Desktop
    • BR: N/A
    • BL: N/A

Open the Mission Control application and create four new linear horizontal Spaces.


Turn Dock hiding on, maximize the size of the Dock, and remove all unnecessary programs from the Dock.

Developer Tools

Terminal Customization

The terminal application is a developer’s main tool.

Download the Solarized color themes, and unzip.

In Terminal Settings, import a new Profile, and choose the solaraized/ Dark ansi.terminal theme.

Set the Solarized Dark profile theme as default.

Increase font size to 18.

Restore ~/.bash_profile:

# ~/.bash_profile


export PS1=" --->> "
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced


alias ll="ls -lahG"

alias gb="git branch"
alias gd="git diff"
alias gl="git log"
alias glt="git log --graph --decorate --oneline --full-history --all --simplify-by-decoration"
alias glsd="git ls-files --deleted"
alias gpom="git pull origin master"
alias gr="git remote -v"
alias gs="git status"

Startup Agents

Review startup agents, and remove as necessary:

launchctl list | grep -v -e '' # list
launchctl remove # remove

SSH Keys

SSH keys establish your identity, and are a prerequisite for using git and connecting via ssh to known servers.

Generate new ssh keys.

ssh-keygen -t rsa -b 4096 -C # generate new key pair
eval "$(ssh-agent -s)" # start the ssh-agent in the background
ssh-add ~/.ssh/id_rsa # add to keychain

If running OS Sierra 10.12.2 or later, create/update ~/.ssh/config to automatically load keys into the ssh-agent and store passphrases in your keychain:

Host *
 AddKeysToAgent yes
 UseKeychain yes
 IdentityFile ~/.ssh/id_rsa

Finally, copy the public key and add to GitHub and other hosts, as necessary.

pbcopy < ~/.ssh/ # copy to clipboard


Xcode is a prerequisite for the homebrew package manager.

Create a new Apple ID, and verify your email.

Download Xcode. It might take 30 minutes. View progress from the Launchpad app.

Some homebrew formulae like git and ruby-build might need xcode command line tools, so install those now:

xcode-select --install

Homebrew Package Manager

Homebrew is a package manager for mac os which is used to install applications, programming languages, command-line tools, etc.. It’s trusted and maintained by a large community of developers.

Install the Homebrew package manager:

/usr/bin/ruby -e "$(curl -fsSL"

Turn off brew analytics:

brew analytics off

Install Homebrew Cask for downloading native applications.

brew tap caskroom/cask


Install and/or open Google Chrome, and set it as the default browser.

brew cask install google-chrome

Open chrome and sign-in as an existing chrome user.

Install or re-configure Ghostery to block browser activity trackers.

Atom Text Editor

Install the Atom text editor.

brew cask install atom

Restoring Atom Preferences and Settings (optional)

Install sync-settings.

apm install sync-settings

Find an existing github personal access token, or generate a new token. It should have permission to create gists.

Find the id of an existing github gist which contains previous atom sync settings, or create a new gist.

In atom’s package settings, input your github access token and gist id. If you have trouble finding the package settings, try opening a new atom window to reveal a warning message and link to the package settings.

Finally, click “restore” to restore text editor settings. The next time you open a new atom window, you should see a sync success message.


Install Git.

brew install git

Git Credentials

Configure Git credentials:

git config --global "John Doe"
git config --global
git config --global core.editor atom

Use an email address which has been linked to your GitHub profile and verified.

Rubygems Credentials (optional)

Configure credentials:

mkdir ~/.gem
curl -u MY_RUBYGEMS_USERNAME > ~/.gem/credentials; chmod 0600 ~/.gem/credentials

Type your password when prompted.

Development Environment Setup

Many of the following sections are optional, depending on what type of development environment you need.

Languages and Frameworks


As a developer working on more than one ruby project, it sometimes becomes necessary to specify different ruby versions for each project. Rbenv makes switching ruby versions easy. Ruby-build, a component of rbenv, facilitates installation of ruby versions.

brew install rbenv
rbenv init # and follow the instructions to add to ~/.bash_profile: eval "$(rbenv init -)"

Restart your terminal for the profile changes to take place.

Use rbenv to install a ruby version and set your computer to use it:

rbenv install 2.3.5 # to install a specific ruby version from the internet
rbenv global 2.3.5 # to set a specific ruby version for use

If you run into trouble, make sure you have installed xcode command line tools and these core libraries: brew install openssl libyaml libffi.

Ruby Gems

Install global gems, including the bundler package manager:

gem install bundler
Ruby on Rails

Install ruby on rails:

gem install rails


Install python (includes the pip package manager):

brew install python3
Python Packages
pip3 install django
pip3 install flask



Check if NVM is installed:

command -v nvm

Install NVM:

curl -o- | bash

This also installs the node package manager (npm).

Use NVM to check for available Node.js versions, install a specific version:

nvm ls-remote  # checks for available versions
nvm install 8.9.3 # installs a specific version, and automatically starts using it
Node Packages

Install the express application generator:

npm install express-generator -g
React Native
npm install react-native-cli -g

see also: react-native android development environment setup guide


cd my_app/
npm install -g bower
# /usr/local/bin/bower -> /usr/local/lib/node_modules/bower/bin/bower
# bower@1.4.1 /usr/local/lib/node_modules/bower




brew install postgresql
brew services start postgresql
createdb # to create a database named after your root database user, which is named after your mac username; avoids `psql: FATAL:  database my_db_user does not exist`

If desired, set a password for the database root user.

psql -U my_db_user -c "ALTER USER my_db_user WITH PASSWORD 'CHANGE_ME';"

If you want to require password authentication, find the location of the pg_hba.conf file using psql -U my_db_user -c "SHOW hba_file;", and edit it to resemble to the following template:

# TYPE  DATABASE        USER            ADDRESS                 METHOD
local   all             all                                     md5
host    all             all               md5
host    all             all             ::1/128                 md5

Basically you are just changing the methods from trust to md5. Restart the server to apply the authentication changes.

brew services restart postgresql
psql -U my_db_user # you should now be prompted for a password

Helpful psql commands and their SQL equivalents:

SELECT * FROM pg_user;
-- or... `\du`

SELECT * FROM pg_database;
-- or... `\l`

SELECT * FROM pg_table WHERE schema_name = 'my_db';
-- or... `\connect my_db` and `\dt`

Optionally install the pg gem/driver if you are going to be connecting with a Ruby on Rails app. Find the pg_config file with psql -U my_db_user -c "SHOW config_file;".

gem install pg
# if there is an error and you need to specify the config file: gem install pg -- --with-pg-config=/usr/local/bin/pg_config

Optionally create an application database and database user.

CREATE USER app_user WITH password 'CHANGE_ME';

Finally, install pgAdmin or pSequel or Postico database management software. Specify your root database user credentials when connecting to the local database server.

brew cask install postico # or... brew cask install psequel


Install MySQL:

brew install mysql
brew services start mysql
mysql -uroot # log-in as the root user

If desired and necessary, secure the connection:

DELETE FROM mysql.user WHERE host <> 'localhost' OR USER = "";
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('cleartext password');

Helpful mysql commands:

SELECT * FROM mysql.user;
SELECT distinct table_schema FROM information_schema.tables; -- or `SHOW DATABASES;`
SELECT * FROM information_schema.tables;
SELECT * FROM information_schema.tables WHERE table_schema = 'my_db';

Finally, install Sequel Pro database management software. Specify your root database user credentials when connecting to the local database server.

brew cask install sequel-pro


Install mongoDB.

brew install mongodb

Follow post-installation instructions.

brew services start mongodb

FYI - the mongo config file specifies the expected paths to the mongo data directory and logfile.

cat /usr/local/etc/mongod.conf

Check your version.

mongo --version
MongoDB shell version: 3.2.9

Run mongo.


Helpful mongo shell commands:

db # to show the active database
show dbs # to show all databases (this doesn't work?)
use myNewDatabase # create/use a new database
show collections # list all collections in the current database (alternate)
db.getCollectionNames() # list all collections in the current database
db.myCollection.insert( { x: 1 } ); # insert a new record
db.myCollection.insert( { y: 2 } );
db.myCollection.find().pretty() # print collection
db.myCollection.find({x:1}).pretty() # find a record matching given query conditions


Install redis.

brew install redis
brew services start redis

Login to redis:



Install elasticsearch.

brew install elasticsearch

NOTE: If you get the error Java 1.7+ is required to install this formula., run: brew tap caskroom/versions and brew cask install java7 and optionally manage java versions with jenv.

Run elasticsearch.



Install phantomjs (

brew install phantomjs


If using the rails-erd gem, satisfy ruby-graphviz dependency by installing the graphviz library.

brew install graphviz

Server Management

Heroku Credentials

Download heroku toolbelt to enable heroku command line tools.

brew install heroku-toolbelt
heroku login