LoginSignup
1
0

More than 5 years have passed since last update.

Rubyの環境構築(Rails含む)

Posted at

Homebrewをインストールする
rbenvをインストールする
$ brew install rbenv
必要なバージョンのrubyをインストールする

$ rbenv install -l
$ rbenv install 2.3.0
$ rbenv rehash
$ rbenv global 2.3.0

リンクがきちんと切り替わらない

ここまでだと、rbenv versionruby -vした時とでバージョンが一致しない。

$ rbenv version
#=> 2.3.0 (set by /Users/qiushi/.rbenv/version)
$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

インストールは正しくできているが、読まれるパスにないことがどうやら原因。
https://www.d-wood.com/blog/2016/02/02_7781.html
http://easyramble.com/rbenv-ruby-version-trouble.html
http://qiita.com/yunzeroin/items/33a51c805e60ed5eca0e

~/.bashrc
#rbenvのバージョンを起動時に反映させるのだとか
eval "$(rbenv init -)"
~/.bash_profile
#~/.bashrc?を反映するための一行
test -r ~/.bashrc && . ~/.bashrc

BundlerをGemでインストール

$ rbenv exec gem install bundler
$ rbenv rehash

Railsをインストール

Gemfileにrailsをインストールするようにコメントインなり追記するなりする。
その後、ローカルに直接ではなく、作業ディレクトリにRailsをインストールするために--pathを指定する。
$ bundle install --path vendor/bundle
この場合、railsを実行するためにはbundleを通さなければならない。
$ bundle exec rails server

1
0
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
1
0