Edited at

Ruby2.0, Rails4.0 beta1のインストール

More than 5 years have passed since last update.


Ruby2.0のインストール

homebrewを使い、rbenv, ruby-buildでRubyをビルドする。


rbenv, ruby-build

homebrewは既にインストールされてる前提で。

$ brew install rbenv

$ brew install ruby-build


openssl, readline

OpenSSL, コンソールでの日本語利用のため、これらもインストールしておく。

$ brew install openssl

$ brew install readline

$ brew link openssl readline

こちらの記事

homebrew で入れた openssl を使って Ruby をコンパイルすると SSL 利用時に証明書エラーが発生する場合の対応

を参考に、curl-ca-bundleも。

$ brew install curl-ca-bundle

$ cp /usr/local/Cellar/curl-ca-bundle/1.87/share/ca-bundle.crt /usr/local/etc/openssl/cert.pem


Ruby

オプションつけて、rubyをインストール。

$ RUBY_CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline` --with-openssl-dir=`brew --prefix openssl`" rbenv install 2.0.0-p0

早速Ruby2.0をデフォルトに。

$ rbenv global 2.0.0-p0

$ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]

bundlerも最後に入れとく。

$ gem install bundler

$ rbenv rehash
$ gem list bundler

*** LOCAL GEMS ***

bundler (1.3.0)


Rails4.0 beta1のインストール

やっとgemでインストールできるようになった。。

$ gem install rails -v 4.0.0.beta1

$ rbenv rehash
$ rails -v
Rails 4.0.0.beta1

試しにrails newしてみんとす

$ rails new hoge

create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/views/layouts/application.html.erb
create app/mailers/.keep
create app/models/.keep
create app/controllers/concerns/.keep
create app/models/concerns/.keep
create bin
create bin/bundle
create bin/rails
create bin/rake
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/backtrace_silencers.rb
create config/initializers/filter_parameter_logging.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/secret_token.rb
create config/initializers/session_store.rb
create config/initializers/wrap_parameters.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create lib
create lib/tasks
create lib/tasks/.keep
create lib/assets
create lib/assets/.keep
create log
create log/.keep
create public
create public/404.html
create public/422.html
create public/500.html
create public/favicon.ico
create public/robots.txt
create test/fixtures
create test/fixtures/.keep
create test/controllers
create test/controllers/.keep
create test/mailers
create test/mailers/.keep
create test/models
create test/models/.keep
create test/helpers
create test/helpers/.keep
create test/integration
create test/integration/.keep
create test/test_helper.rb
create tmp/cache
create tmp/cache/assets
create vendor/assets/javascripts
create vendor/assets/javascripts/.keep
create vendor/assets/stylesheets
create vendor/assets/stylesheets/.keep
run bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Installing rake (10.0.3)
Using i18n (0.6.4)
Installing minitest (4.6.2)
Using multi_json (1.6.1)
Using atomic (1.0.1)
Using thread_safe (0.1.0)
Using tzinfo (0.3.35)
Using activesupport (4.0.0.beta1)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0.beta1)
Using mime-types (1.21)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.5.3)
Using actionmailer (4.0.0.beta1)
Using activemodel (4.0.0.beta1)
Using activerecord-deprecated_finders (0.0.3)
Using arel (4.0.0.beta1)
Using activerecord (4.0.0.beta1)
Using bundler (1.3.0)
Installing coffee-script-source (1.5.0)
Installing execjs (1.4.0)
Installing coffee-script (2.2.0)
Using json (1.7.7)
Using rdoc (3.12.2)
Using thor (0.17.0)
Using railties (4.0.0.beta1)
Installing coffee-rails (4.0.0.beta1)
Using hike (1.2.1)
Installing jbuilder (1.0.2)
Installing jquery-rails (2.2.1)
Using tilt (1.3.4)
Using sprockets (2.9.0)
Using sprockets-rails (2.0.0.rc3)
Using rails (4.0.0.beta1)
Installing sass (3.2.6)
Installing sass-rails (4.0.0.beta1)
Installing sqlite3 (1.3.7)
Installing turbolinks (1.0.0)
Installing uglifier (1.3.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

生成されたGemfileは以下の様な感じだった。


Gemfile

source 'https://rubygems.org'                                                                       

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0.beta1'

gem 'sqlite3'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 4.0.0.beta1'
gem 'coffee-rails', '~> 4.0.0.beta1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.0.1'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano', group: :development

# To use debugger
# gem 'debugger'


以上。あとでrails g scaffoldとかしてみよう。