The purpose of this step by step tutorial is to provide a very simple example of configuring a minimal Rails environment.
- macOS 10.14.4 or later
-
download and install Xcode from Mac App Store
-
in Terminal.app, install command line tools
xcode-select --install
-
download and/or install MacPorts version appropriate for your macOS version
-
if macOS version >= 10.14 and < 10.15
-
if macOS version >= 10.15 and < 10.16
WORKING_DIRECTORY=${HOME}/macports.dir/projects/macports mkdir -p ${WORKING_DIRECTORY} cd ${WORKING_DIRECTORY} git clone https://github.com/macports/macports-base.git cd ${WORKING_DIRECTORY}/macports-base ./configure --enable-readline make sudo make install make distclean sudo port selfupdate
-
-
in Terminal.app, clone this repository
git clone https://github.com/conradwt/rails-setup-guide-for-macos
-
in Terminal.app, change directory to the cloned repository
cd rails-setup-guide-for-macos
-
in Terminal.app, install required ports from MacPorts
chmod +x install-ports.sh ./install-ports.sh
-
in Terminal.app, set up PostgreSQL Server
sudo mkdir -p /opt/local/var/db/postgresql11/defaultdb sudo chown postgres:postgres /opt/local/var/db/postgresql11/defaultdb sudo su postgres -c '/opt/local/lib/postgresql11/bin/initdb -D /opt/local/var/db/postgresql11/defaultdb'
-
in Terminal.app, set PostgreSQL 11 as the default version
sudo port select postgresql postgresql11
-
in Terminal.app, start the PostgreSQL Server
pgstart
-
download and install Node
mkdir -p "${HOME}/.npm-packages" npm config set prefix "${HOME}/.npm-packages" NPM_PACKAGES="${HOME}/.npm-packages" export PATH="$NPM_PACKAGES/bin:$PATH"
-
in Terminal.app, install RBenv
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv chmod -R go-w $HOME/.rbenv cd ~/.rbenv && src/configure && make -C src export PATH=${HOME}/.rbenv/bin:${PATH} eval "$(rbenv init -)"
-
in Terminal.app, install all of the approved plugins RBenv plugins
chmod +x $HOME/rails-setup-guide-for-macos/install-rbenv-plugins.sh $HOME/rails-setup-guide-for-macos/install-rbenv-plugins.sh cp $HOME/rails-setup-guide-for-macos/sample.default-gems $HOME/.rbenv/default-gems
-
in Terminal.app, install Ruby
rbenv install 2.7.1 rbenv global 2.7.1
-
in Terminal.app, install Rails
gem update --system rbenv rehash
-
in Terminal.app, install Oh My ZSH
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" npm install -g spaceship-prompt git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting mkdir -p $HOME/.zsh/completions curl https://github.com/github/hub/blob/master/etc/hub.zsh_completion > ~/.zsh/completions/_hub sudo chmod +x $HOME/.zsh/completions/_hub cp -r $HOME/rails-setup-guide-for-macos/sample.zshrc.d ~/.zshrc.d cp $HOME/rails-setup-guide-for-macos/sample.zshrc ~/.zshrc cp $HOME/rails-setup-guide-for-macos/sample.zshenv ~/.zshenv
-
in Terminal.app, open another terminal
Command N
-
download and install VS Code Insiders
-
in Terminal.app, install VS Code Extensions
chmod +x $HOME/rails-setup-guide-for-macos/vscode/vscode-extensions.zsh ./$HOME/rails-setup-guide-for-macos/vscode/vscode-extensions.zsh
-
install VS Code Insiders command line interface (CLI)
-
in VS Code Insiders.app, type
Command Shift P
-
in the input field that appears, type
shell command install
-
select the the following text
Shell Command: Install `code-insiders` command in PATH
-
-
download and install Heroku Toolbelt
-
in Terminal.app, set the Git completion
cp sample.git-completion.sh $HOME/.git-completion.sh
-
in Chrome, create a Github.com account
Note: Skip this step if you already have an account.
-
in Terminal.app, create Git configuration and global files
cp sample.gitconfig ~/.gitconfig cp sample.gitignore_global ~/.gitignore_global
-
in Terminal.app, edit .gitconfig file
-
change
excludesfile
setting:git config --global core.excludesfile ~/.gitignore_global
-
change
name
andemail
for Github accounte.g.
git config --global user.name "John Doe" git config --global user.email "johndoe@example.com"
-
set the default pager
git config --global core.pager ''
-
-
create and/or setup SSH keys
-
if you have SSH keys
-
create SSH folder in home directory
mkdir -p $HOME/.ssh
-
copy your SSH keys to the above folder
-
set permissions
chmod 700 $HOME/.ssh chmod 600 $HOME/.ssh/id_rsa chmod 644 $HOME/.ssh/id_rsa.pub
-
-
if you don't have SSH keys
-
Generating a new SSH key and adding it to the ssh-agent
Note: Please select Mac link at the top of the page.
-
-
-
Add SSH public key to Github
-
in the Terminal.app, testing your SSH connection
-
in Terminal.app, set the terminal
cp sample.terminal $HOME/.
-
in Terminal.app menu, Shell -> Import, select
sample.terminal
fileTerminal -> Preferences -> Profiles, select the 'sample' profile in the left sidebar, click Default at the bottom of the window
Bug reports and feature requests can be filed for the rails-setup-guide-for-macos
project here:
Follow Conrad Taylor on Twitter (@conradwt)
This repository is released under the MIT License.
© Copyright 2014 - 2019 Conrad Taylor. All Rights Reserved.