LoginSignup
20
23

More than 5 years have passed since last update.

rvm から rbenv に移行して、rails 開発環境を作る

Last updated at Posted at 2014-11-29

自分向け作業メモ

目次

  • rvm の削除
  • rbenv のインストール
  • rails 環境構築

rvm の削除

$ rvm seppuku
  • 切腹!!

一部削除できないので、rm も使う

$ rm -rf ~/.rvm

rbenv のインストール

brew update

$ brew update
error: Your local changes to the following files would be overwritten by merge:
        README.md
Please, commit your changes or stash them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

git絡みでエラーが出るので、掃除

$ cd $(brew --prefix)
$ git fetch origin
$ git reset --hard origin/master

$ brew update

install rbenv

$ brew install rbenv
$ brew install ruby-build

.zshrc 設定

if which rbenv > /dev/null; then eval "$(rbenv init - zsh)"; fi

ruby のインストール

インストール可能な一覧の取得

$ rbenv install -l

インストール

$ rbenv install 2.1.5

インストール済一覧

$ rbenv versions

標準で使うruby を設定

$ rbenv global 2.1.5

欲しいバージョンがまだない場合

$ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

rbenv-gem-rehash のインストール

rvm rehash を自動的にやってくれる

$ brew install rbenv-gem-rehash

Bundler のインストール

$ rbenv exec gem install bundler
$ gem list --local

*** LOCAL GEMS ***

bigdecimal (1.2.4)
bundler (1.7.7)
io-console (0.4.2)
json (1.8.1)
minitest (4.7.5)
psych (2.0.5)
rake (10.1.0)
rdoc (4.1.0)
test-unit (2.1.5.0)

bundle exec めんどい対策

$ brew install rbenv-binstubs

rails 環境構築

適当なディレクトリを作る

Gemfile 作成

まずは、rails を vendor/bundle にインストール

$ bundle init

$ cat Gemfile
# A sample Gemfile
source "https://rubygems.org"

gem "rails"

bundle install

$ bundle install --path vendor/bundle --binstubs bundle_bin
rails -v
Rails 4.1.8

rails new

rails new .

Gemfile を上書きするか聞かれるので上書き

以上!!

git 初期設定

$ git init

$ echo "/vendor" >> .gitignore
$ echo "/bundle_bin" >> .gitignore

$ git add -all
$ git ci -m "First commit"

参考資料

20
23
1

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
20
23