ruby 環境構築 @Niigata.rb#3

82d6167c4d14393c2e20b37a74b363c5?s=47 kasacchiful
August 31, 2013
300

ruby 環境構築 @Niigata.rb#3

Niigata.rb #3 で発表した資料です。

82d6167c4d14393c2e20b37a74b363c5?s=128

kasacchiful

August 31, 2013
Tweet

Transcript

  1. 4.

    ຊ೔΍Δ͜ͱ Mac homebrew + rbenv, ruby-build Linux ( CentOS )

    rbenv, ruby-build Windows One-Click Installer bundlerʹΑΔgem؅ཧ αϯϓϧΞϓϦέʔγϣϯ࣮ߦ 13೥8݄31೔౔༵೔
  2. 8.

    ࣮ߦ؀ڥߏங (Macฤ) ߏங؀ڥ MacOS X 10.8.3 homebrew 0.9.4 git 1.7.12.4

    (Apple Git-37) rbenv 0.4.0 ruby-build 20130518 13೥8݄31೔౔༵೔
  3. 9.

    ࣮ߦ؀ڥߏங (Macฤ) HomebrewΠϯετʔϧ ཁjava, Xcode command line tools XcodeΛ։͖ɺʮpreferencesʯ 㱺ʮdownloadsʯ㱺ʮComponentsʯ͔Β

    ʮCommand Line ToolsʯΛΠϯετʔϧ Homebrew αΠτͷΠϯετʔϧίϚϯυ࣮ߦ 13೥8݄31೔౔༵೔
  4. 11.

    ࣮ߦ؀ڥߏங (Macฤ) rbenv, rubu-buildΠϯετʔϧ $ brew install openssl $ brew

    install readline $ brew install ruby-build $ brew install rbenv $ echo ‘eval “$(rbenv init -)”’ >> ~/.bash_profile $ source ~/.bash_profile 13೥8݄31೔౔༵೔
  5. 12.

    ࣮ߦ؀ڥߏங (Macฤ) rbenv, rubu-buildΠϯετʔϧ $ RUBY_CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline` --with-openssl-dir=`brew --prefix

    openssl`" rbenv install 2.0.0-p195 $ rbenv rehash $ rbenv global 2.0.0-p195 ## ϓϩδΣΫτ͝ͱʹόʔδϣϯࢦఆ͢Δ৔߹ $ rbenv local 2.0.0-p195 ɹ#=> .ruby-versionϑΝΠϧʹॻ͖ࠐ·ΕΔ 13೥8݄31೔౔༵೔
  6. 13.

    ࣮ߦ؀ڥߏங (Macฤ) ಈ࡞֬ೝ $ irb > require ‘openssl’ => true

    > require ‘zlib’ => true > require ‘open-uri’ => true > open (“https:/ /www.google.com”).read => <doctype html>... 13೥8݄31೔౔༵೔
  7. 18.

    # groupadd -g 600 staff # yum install git #

    cd /usr/local/src # git clone https:/ /github.com/sstephenson/rbenv.git rbenv # chgrp -R staff rbenv # chmod -R g+rwxXs rbenv # vi /etc/profile.d/rbenv.sh export RBENV_ROOT=/usr/local/rbenv export PATH="$RBENV_ROOT/bin:$PATH" eval "$(rbenv init -)" 13೥8݄31೔౔༵೔
  8. 19.

    # cd /usr/local/src/rbenv # mkdir plugins # cd /usr/local/src/rbenv/plugins #

    git clone https:/ /github.com/sstephenson/ruby-build.git # chgrp -R staff ruby-build # chmod -R g+rwxs ruby-build 13೥8݄31೔౔༵೔
  9. 20.

    # cd /usr/local/src/rbenv/plugins # git clone https:/ /github.com/sstephenson/rbenv-default-gems.git # chgrp

    -R staff rbenv-default-gems # chmod -R g+rwxs rbenv-default-gems # cd /usr/local/src/rbenv # vi default-gems bundler pry rbenv-rehash 13೥8݄31೔౔༵೔
  10. 21.

    (rbenv installதͷcheckͰ͍Ζ͍Ζ଍Γͳ͍ͷͰɺyum install͓ͯ͘͠) # yum install gcc make zlib-devel readline-devel

    openssl-devel # rbenv install 1.9.3-p448 # rbenv install 2.0.0-p247 # rbenv rehash # rbenv global 2.0.0-p247 13೥8݄31೔౔༵೔
  11. 32.

    ࣮ߦ؀ڥߏங (bundlerฤ) rubyϓϩδΣΫτ foo ͷ৔߹ $ cd ~/foo $ bundle

    init #=> Gemfileͻͳܗ࡞੒ # A sample Gemfile source "https:/ /rubygems.org" # gem "rails" gem ‘pp’ $ bundle install --path=vendor/bundle #=> ./vendor/bundle ʹΠϯετʔϧ 13೥8݄31೔౔༵೔
  12. 33.

    ࣮ߦ؀ڥߏங (bundlerฤ) rubyϓϩδΣΫτ foo ͷ৔߹ $ vi main.rb require ‘bundler/setup‘

    #=> bundlerͷgemʹݻఆ require ‘pp‘ #=> ݸผʹrequire Bundler.require #=> Ұׅrequire pp “Foo!” $ ruby main.rb 13೥8݄31೔౔༵೔
  13. 34.

    ࣮ߦ؀ڥߏங (bundlerฤ) railsϓϩδΣΫτ hoge ͷ৔߹ $ cd ~/hogehoge $ bundle

    init #=> Gemfileͻͳܗ࡞੒ # A sample Gemfile source "https:/ /rubygems.org" gem "rails" $ bundle install --path=vendor/bundle #=> ./vendor/bundle ʹΠϯετʔϧ 13೥8݄31೔౔༵೔
  14. 35.

    ࣮ߦ؀ڥߏங (bundlerฤ) railsϓϩδΣΫτ hoge ͷ৔߹ $ bundle exec rails new

    hoge -B $ cd hoge $ bundle install --path=vendor/bundle 13೥8݄31೔౔༵೔
  15. 37.

    ·ͱΊ Mac Linux ( CentOS ) rbenv, ruby-build Windows όΠφϦΠϯετʔϧ

    bundlerʹΑΔgem؅ཧ ϓϩδΣΫτ͝ͱʹ࣋ͭͱศར 13೥8݄31೔౔༵೔