[Ruby] Building an environment for Rails engineers ruby2.7.1

2 minute read

I wrote it as a memorandum because mac failed and needed to be replaced. I also list non-essential settings such as heroku and item2 settings.

Command Line Tools

xcode-select --install

Is heavy, so install xcode and do it here

 Screenshot 2020-06-20 10.15.43.png

Confirmation

 xcode-select -version

Homebrew

https://brew.sh/index_ja

Confirmation

brew -v

rbenv

brew install rbenv ruby-build

zshrc setting

If not ####

vi .zshrc

Register with ####.zshrc

/.zshrc


# zsh-completions settings
if [-e /usr/local/share/zsh-completions ]; then
    fpath=(/usr/local/share/zsh-completions $fpath)
fi
autoload -U compinit
compinit -u


# prompt
PROMPT='%[email protected]%n %F{1}%~%f$ '

##################################################
### aliases
# Git series
alias g='git'
alias gs='git status'
alias gb='git branch'
alias gc='git clone'
alias gco='git checkout'
alias gct='git commit'
alias gg='git grep'
alias ga='git add'
alias gd='git diff'
alias gl='git log'
alias gcma='git checkout master'
alias gfu='git fetch upstream'
alias gfo='git fetch origin'
alias gmod='git merge origin/develop'
alias gmud='git merge upstream/develop'
alias gmom='git merge origin/master'
alias gcm='git commit -m'
alias gpo='git push origin'
alias gpom='git push origin master'
alias gst='git stash'
alias gsl='git stash list'
alias gsu='git stash -u'
alias gsp='git stash pop'

export PATH="/usr/local/bin:$PATH"
export PATH="$HOME/.rbenv/shims:$PATH"

export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])"
export CC=/usr/bin/gcc

# Setup Compiler paths for readline and openssl
local READLINE_PATH=$(brew --prefix readline)
local OPENSSL_PATH=$(brew --prefix openssl)
export LDFLAGS="-L$READLINE_PATH/lib -L$OPENSSL_PATH/lib"
export CPPFLAGS="-I$READLINE_PATH/include -I$OPENSSL_PATH/include"
export PKG_CONFIG_PATH="$READLINE_PATH/lib/pkgconfig:$OPENSSL_PATH/lib/pkgconfig"

# Use the OpenSSL from Homebrew instead of ruby-build
# Note: the Homebrew version gets updated, the ruby-build version doesn't
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$OPENSSL_PATH"

# Place [email protected] at the beginning of your PATH (preempt system libs)
export PATH=$OPENSSL_PATH/bin:$PATH

# Load rbenv
eval "$(rbenv init -)"

# Extract the latest version of Ruby so you can do this:
# rbenv install $LATEST_RUBY_VERSION
export LATEST_RUBY_VERSION=$(rbenv install -l | grep -v-| tail -1)


export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PKG_CONFIG_PATH=/usr/local/opt/[email protected]/lib/pkgconfig

# Turn off the warning output with db:create for Ruby 2.7 and Rails 6
# export RUBYOPT='-W:no-deprecated -W:no-experimental'

Reflect

source ~/.zshrc

Confirmation

rbenv

ruby install

Confirm the installable version

rbenv install -l

install

rbenv install 2.7.1

I saw this when I could not (https://github.com/rbenv/ruby-build/issues/1409)

Global settings

rbenv global 2.7.1

Confirmation

ruby --version

Bundler

** A tool for managing gem dependencies and versions **

gem install bundler

Rails

gem install rails
rbenv rehash

yarn

Required for installing webpacker

brew install yarn

There is no knowledge, but it seems that it is good to put this (Reference)

brew install rbenv-communal-gems

webpacker

Since webpacker has become a standard specification from Rails 6, it is necessary to install yarn.

rails webpacker:install

Eliminate warning output with db:create for Ruby 2.7 and Rails 6

#### **`/.zshrc`**

export RUBYOPT=’-W:no-deprecated -W:no-experimental’

# MySQL

brew install [email protected]

#### Confirmation

mysql –version

# git ssh setting
https://qiita.com/shizuma/items/2b2f873a0034839e47ce

# Commands to be happy with git
- git-prompt
- aws-cli
- jq command
- favdir
- colordiff
- tree (either way)

reference:
https://qiita.com/west-hiroaki/items/9560f0504c3bdfe970f5#shell%E3%81%AB%E8%A8%AD%E5%AE%9A%E3%82%A4%E3%83%B3%E3% 82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E3%82% B3%E3%83%9E%E3%83%B3%E3%83%89

# Heroku settings

brew tap heroku/brew && brew install heroku

To check
https://devcenter.heroku.com/articles/heroku-cli

# iTerm2 settings
https://note.com/digiangler777/n/n8206e2163904

# Finder Show hidden files

defaults write com.apple.finder AppleShowAllFiles TRUE

killall Finder ``` Open Finder again

Tags: ,

Updated: