LoginSignup
5
5

More than 5 years have passed since last update.

Ruby環境構築

Last updated at Posted at 2015-02-11

Ruby環境構築のための手順

構築環境

  • Mac OS X 10.10.2
  • Homebrew インストール済み

rbenv

複数バージョンのrubyを使えるようにする

$ brew install rbenv ruby-build
$ echo eval "$(rbenv init -)" >> ~/.zshrc

$ rbenv install --list
$ rbenv install 2.2.0
$ rbenv global 2.2.0

bundler

Gemをプロジェクトごとに管理するのに使う

$ rbenv exec gem install bundler
$ rbenv rehash

gemをインストールする場合は、Gemfileに記載し、bundle installを実行する

Railsのローカルインストール

Gemfileを作成

Gemfile
source "http://rubygems.org"
gem "rails"

bundle install実行

$ rbenv exec bundle install --path vendor/bundle
  • --pathを付けることでローカルにインストールできる。
  • 一回 pathを指定すると、その後はpathを指定しなくてもローカルにインストールされる。

Bundle exec の省略

binstubsプラグインをインストール

$ cd ~/.rbenv/plugins
$ git clone git://github.com/ianheggie/rbenv-binstubs.git

.zshrcにパスを追加

~/.zshrc
export PATH=./vendor/bin:$PATH

補足

  • bundle install --path xxxx のパスを戻す場合
$ bundle install --system
  • bundlerでインストールしたgemがコマンドで見つからない場合
$ rbenv rehash
5
5
2

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
5
5