LoginSignup
2
1

More than 5 years have passed since last update.

rbenv,ruby-buildを使ってRails環境を構築するまで(Ubuntu)

Last updated at Posted at 2016-08-05

しょっちゅうググり直してしまうので、自分用にまとめました。
rbenvは複数ユーザーで共有したいので、/usr/local/rbenv にインストールすることにします。

参考)
CentOSでrbenvをシステムにインストールする

install necessary packages

$ sudo apt-get -y install libssl-dev zlib1g-dev libreadline-dev libmysqlclient-dev sqlite3 libsqlite3-dev g++ git curl

install rbenv

$ cd /usr/local
$ sudo git clone git://github.com/sstephenson/rbenv.git rbenv

make export path setting

--no-rehash をつけないとログインのたび rehash するので遅くなるそうです。

/etc/profile.d/rbenv.sh
export RBENV_ROOT="/usr/local/rbenv"
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init --no-rehash -)"

load setting

$ source /etc/profile.d/rbenv.sh

confirm rbenv installed

$ type rbenv

install ruby-build

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

install Ruby

# rbenv install 2.3.1
# rbenv global 2.3.1

install bundler

# gem install bundler --no-ri --no-rdoc

install Rails

$ mkdir project
$ cd project
$ bundle init
Gemfile
source "https://rubygems.org"

gem "rails"

システムのgemにインストールせずにvendor/bundle以下に配置する

$ bundle install --path vendor/bundle
$ bundle exec rails new .

補足

bundle install で An error occurred while installing pg (0.17.1) というエラーが起きた時の対処

postgresqlとlibpgを入れることで解決できた

$ sudo apt-get install postgresql-9.3
$ sudo apt-get install libpq-dev
2
1
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
2
1