LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 3 years have passed since last update.

Ruby on Railsローカル開発環境構築メモ

Last updated at Posted at 2019-12-15

Ruby + Rails環境構築メモ.

■ Homebrew.

HomebrewにはXcodeが必要なので導入.

$ xcode-select --install
$ xcodebuild -version

公式サイトを要確認.

$ https://brew.sh/index_ja/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

■ rbenv.

$ brew install rbenv

Macの場合は環境変数を初期化.

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile

バージョン確認.

$ rbenv -v

■ ruby.

# インストール対象の確認.
$ rbenv install --list
# 対象バージョンをインストール.
$ rbenv install 2.6.5
# システム全体で利用するRubyのバージョンを指定.
$ rbenv global 2.6.5

正しくrbenvがインストール出来たか確認.

$ ruby -v
$ which ruby

■ RubyGems.

$ gem update --system
$ gem -v

# インストール済みのGemlist確認.
$ gem list

■ Bundler.

Bundlerはプロジェクトで使うgemを束ね、どのバージョンが必要かを明示する仕組み.

$ gem install bundler

# ■ 代表的なBundlerコマンド.
# bundle install (Gemfileに記述されたgemインストール) ※ installは省略可.
# bundle exec (Bundlerが管理するgemを利用出来る状態でコマンド実行)
# bundle init (初期状態のGemfileをカレントディレクトリに作成)
# bundle update (Bundlerが管理するgemのパッケージ更新)

■ Rails.

$ gem install rails -v 5.2.2

■ PostgreDB.

$ brew install postgresql
$ postgres -V

PostgreDBの起動停止は以下コマンドを実行.

$ brew services start postgresql
$ psql postgres
$ ¥q
$ brew services stop postgresql

■ 参考文献.

:books: 現場で使える Ruby on Rails 5速習実践ガイド.

0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up