Railsで開発できる環境を整える(RVM&諸々インストール編)

とりあえずRubyは新しめなやつが入ってました。

$ ruby -v ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10]

  が、そう言えばRVMってどうしたっけか…?複数バージョンやりくり出来るヤツ。 とりあえずrvm叩いてみると無いって言われるw

$ rvm -bash: rvm: command not found

  でもディレクトリもコマンドもあるみたい。

$ cd ~/.rvm/ $ ls bin/rvm bin/rvm

  listを表示してみると1.9.2が入ってた。

$ bin/rvm list rvm rubies => ruby-1.9.2-p136 [ x86_64 ]

  そしたら、こっとに1.9.3入れてやったほがイイかな、と。 とりあえずパス通す&ターミナル開いた時にrvmの設定を読み込んでやるっていう事で、 .bash_profileに以下の1行を追加します。

-s "$HOME/.rvm/scripts/rvm" && source "$HOME/.rvm/scripts/rvm"

  よーし1.9.3入れちゃるぞーって事でrvm install 1.9.3叩いたら、、

$ rvm install 1.9.3 Installing Ruby from source to: /Users/eshinohara/.rvm/rubies/ruby-1.9.3, this may take a while depending on your cpu(s)... -略- ERROR: The requested url does not exist: 'ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3.tar.bz2' -略- Running autoconf ERROR: Error running 'autoconf', please read /Users/eshinohara/.rvm/log/ruby-1.9.3/autoconf.log ERROR: Skipping configure step, 'configure' does not exist, did autoconf not run successfully? ruby-1.9.3 - #compiling ERROR: Error running 'make ', please read /Users/eshinohara/.rvm/log/ruby-1.9.3/make.log ERROR: There has been an error while running make. Halting the installation.

  なんだろなって事でFTPサーバ覗いてみたら、 ↓のファイルがあったので、 rvm install ruby-1.9.3-p194にしたところ、 ・ruby-1.9.3-p194.tar.bz2 ・ruby-1.9.3-p194.tar.gz ・ruby-1.9.3-p194.zip ↓のようにインストールはじまりました。

$ rvm install ruby-1.9.3-p194 Installing Ruby from source to: /Users/eshinohara/.rvm/rubies/ruby-1.9.3-p194, this may take a while depending on your cpu(s)... ruby-1.9.3-p194 - #fetching ruby-1.9.3-p194 - #downloading ruby-1.9.3-p194, this may take a while depending on your connection... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 9610k 100 9610k 0 0 145k 0 0:01:05 0:01:05 --:--:-- 97247 ruby-1.9.3-p194 - #extracting ruby-1.9.3-p194 to /Users/eshinohara/.rvm/src/ruby-1.9.3-p194 ruby-1.9.3-p194 - #extracted to /Users/eshinohara/.rvm/src/ruby-1.9.3-p194 ruby-1.9.3-p194 - #configuring ruby-1.9.3-p194 - #compiling

  Gemsが他と被らないようにって事でgemsetをば。

$ rvm use 1.9.3-1.9.3-p194@rails3tutorial2ndEd --create --default Using /Users/eshinohara/.rvm/gems/ruby-1.9.3-p194 with gemset rails3tutorial2ndEd

  gemの確認してみると、

$ which gem /Users/eshinohara/.rvm/rubies/ruby-1.9.3-p194/bin/gem $ gem -v /Users/eshinohara/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/yaml.rb:56:in `': It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby. 1.8.23

  良さげですが、libyamlが入ってないって言ってます。 で、もっかいRubyインストールしろやと。。切ない。。。   rvmみてたらpackageってのがあって↓こんな風にインストール出来るんすね。

$ rvm package install libyaml Fetching yaml-0.1.3.tar.gz to /Users/eshinohara/.rvm/archives % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 455k 100 455k 0 0 200k 0 0:00:02 0:00:02 --:--:-- 374k Extracting yaml-0.1.3.tar.gz to /Users/eshinohara/.rvm/src Configuring yaml in /Users/eshinohara/.rvm/src/yaml-0.1.3. Compiling yaml in /Users/eshinohara/.rvm/src/yaml-0.1.3. Installing yaml to /Users/eshinohara/.rvm/usr

  で、その後、何度かRubyを入れたり消したりして頑張ったのですが、どうにもならず。。。

ruby-1.9.3-head - Updating #rubygems to the latest. Removing old Rubygems files... -e:1: Use RbConfig instead of obsolete and deprecated Config. Installing rubygems dedicated to ruby-1.9.3-head... Installing rubygems for /Users/eshinohara/.rvm/rubies/ruby-1.9.3-head/bin/ruby ERROR: Error running 'GEM_PATH="/Users/eshinohara/.rvm/gems/ruby-1.9.3-head:/Users/eshinohara/.rvm/gems/ruby-1.9.3-head@global:/Users/eshinohara/.rvm/gems/ruby-1.9.3-head@global" GEM_HOME="/Users/eshinohara/.rvm/gems/ruby-1.9.3-head" "/Users/eshinohara/.rvm/rubies/ruby-1.9.3-head/bin/ruby" "/Users/eshinohara/.rvm/src/rubygems-1.5.2/setup.rb"', please read /Users/eshinohara/.rvm/log/ruby-1.9.3-head/rubygems.install.log WARN: Installation of rubygems did not complete successfully. ruby-1.9.3-head - Updating #rubygems to the latest. Removing old Rubygems files... -e:1: Use RbConfig instead of obsolete and deprecated Config. Installing rubygems dedicated to ruby-1.9.3-head... Installing rubygems for /Users/eshinohara/.rvm/rubies/ruby-1.9.3-head/bin/ruby ERROR: Error running 'GEM_PATH="/Users/eshinohara/.rvm/gems/ruby-1.9.3-head:/Users/eshinohara/.rvm/gems/ruby-1.9.3-head@global:/Users/eshinohara/.rvm/gems/ruby-1.9.3-head@global" GEM_HOME="/Users/eshinohara/.rvm/gems/ruby-1.9.3-head" "/Users/eshinohara/.rvm/rubies/ruby-1.9.3-head/bin/ruby" "/Users/eshinohara/.rvm/src/rubygems-1.5.2/setup.rb"', please read /Users/eshinohara/.rvm/log/ruby-1.9.3-head/rubygems.install.log WARN: Installation of rubygems did not complete successfully.

  もう全部処分して1からやり直す事にしました。。

$ rvm implode WARN: Are you SURE you wish for rvm to implode? This will recursively remove /Users/eshinohara/.rvm and other rvm traces? (type 'yes' or 'no')> yes Removing rvm-shipped binaries (rvm-prompt, rvm, rvm-sudom rvm-shell and rvm-auto-ruby) Removing rvm wrappers in /Users/eshinohara/.rvm/bin Hai! Removing /Users/eshinohara/.rvm

  手順は https://rvm.io//rvm/install/ 本家のRVMの手順に従う形で。。

$ curl -L get.rvm.io | bash -s stable % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 101 8797 101 8797 0 0 3155 0 0:00:02 0:00:02 --:--:-- 31195 Downloading RVM from wayneeseguin branch stable % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 994k 100 994k 0 0 268k 0 0:00:03 0:00:03 --:--:-- 714k Installing RVM to /Users/eshinohara/.rvm/ Adding rvm PATH line to /Users/eshinohara/.bashrc /Users/eshinohara/.zshrc. RVM sourcing line found in /Users/eshinohara/.profile /Users/eshinohara/.bash_profile /Users/eshinohara/.zshrc. # RVM: Shell scripts enabling management of multiple ruby environments. # RTFM: https://rvm.io/ # HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net) # Cheatsheet: http://cheat.errtheblog.com/s/rvm/ # Screencast: http://screencasts.org/episodes/how-to-use-rvm # In case of any issues read output of 'rvm requirements' and/or 'rvm notes' Installation of RVM in /Users/eshinohara/.rvm/ is almost complete: * To start using RVM you need to run `source /Users/eshinohara/.rvm/scripts/rvm` in all your open shell windows, in rare cases you need to reopen all shell windows. # shinodogg, # # Thank you for using RVM! # I sincerely hope that RVM helps to make your life easier and more enjoyable!!! # # ~Wayne RVM reloaded! rvm 1.12.5 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> https://rvm.io/ $ source ~/.rvm/scripts/'rvm' RVM reloaded! $ rvm requirements Notes for Mac OS X 10.6.8, Xcode 3.2.6. For JRuby: Install the JDK. See http://developer.apple.com/java/download/ # Current Java version "1.6.0_26" For IronRuby: Install Mono >= 2.6 For Ruby 1.9.3: Install libksba # If using Homebrew, 'brew install libksba' You can use & download osx-gcc-installer: https://github.com/kennethreitz/osx-gcc-installer ** NOTE: Currently, Node.js is having issues building with osx-gcc-installer. The only fix is to install Xcode over osx-gcc-installer. We had reports of http://hpc.sourceforge.net/ making things work, but it looks like not easiest/safest to setup. To use an RVM installed Ruby as default, instead of the system ruby: rvm install 1.8.7 # installs patch 357: closest supported version rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system.gems # migrate your gems rvm alias create default 1.8.7 And reopen your terminal windows. Xcode 4.2: * is only supported by ruby 1.9.3+ * it breaks gems with native extensions, especially DB drivers. ** Required Xcode Version 3.2.1 (1613) or later, such as 3.2.6 or Xcode 4.1. You should download the Xcode tools from developer.apple.com, since the Snow Leopard dvd install contained bugs. $ vm install 1.9.3 -bash: vm: command not found $ rvm install 1.9.3 Fetching yaml-0.1.4.tar.gz to /Users/eshinohara/.rvm/archives % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 460k 100 460k 0 0 192k 0 0:00:02 0:00:02 --:--:-- 451k Extracting yaml-0.1.4.tar.gz to /Users/eshinohara/.rvm/src Configuring yaml in /Users/eshinohara/.rvm/src/yaml-0.1.4. Compiling yaml in /Users/eshinohara/.rvm/src/yaml-0.1.4. Installing yaml to /Users/eshinohara/.rvm/usr Installing Ruby from source to: /Users/eshinohara/.rvm/rubies/ruby-1.9.3-p194, this may take a while depending on your cpu(s)... ruby-1.9.3-p194 - #fetching ruby-1.9.3-p194 - #downloading ruby-1.9.3-p194, this may take a while depending on your connection... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 9610k 100 9610k 0 0 123k 0 0:01:17 0:01:17 --:--:-- 177k ruby-1.9.3-p194 - #extracting ruby-1.9.3-p194 to /Users/eshinohara/.rvm/src/ruby-1.9.3-p194 ruby-1.9.3-p194 - #extracted to /Users/eshinohara/.rvm/src/ruby-1.9.3-p194 ruby-1.9.3-p194 - #configuring ruby-1.9.3-p194 - #compiling ruby-1.9.3-p194 - #installing Retrieving rubygems-1.8.23 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 371k 100 371k 0 0 269k 0 0:00:01 0:00:01 --:--:-- 1710k Extracting rubygems-1.8.23 ... Removing old Rubygems files... Installing rubygems-1.8.23 for ruby-1.9.3-p194 ... Installation of rubygems completed successfully. ruby-1.9.3-p194 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake). ruby-1.9.3-p194 - #importing default gemsets (/Users/eshinohara/.rvm/gemsets/) Install of ruby-1.9.3-p194 - #complete

  んでgemsetの設定、と。

$ rvm use 1.9.3@rails3tutorial2ndEd --create --default Using /Users/eshinohara/.rvm/gems/ruby-1.9.3-p194 with gemset rails3tutorial2ndEd $ which gem /Users/eshinohara/.rvm/rubies/ruby-1.9.3-p194/bin/gem $ gem -v 1.8.23

  いよいよRailsのインストールですが、その前に.gemrcに以下の設定を入れて、 時間の省略的な。ググったりオンラインのリファレンス見たりするよねぇと。

$ cat ~/.gemrc install: --no-rdoc --no-ri update: --no-rdoc --no-ri

  んで、Rails入れます。

$ gem install rails -v 3.2.3 Fetching: i18n-0.6.0.gem (100%) Fetching: multi_json-1.3.2.gem (100%) -略- uccessfully installed railties-3.2.3 Successfully installed rails-3.2.3 29 gems installed

  無事入った模様です。

$ rails -v Rails 3.2.3

  で、rails newすると、、、ちょ、それキツくないすかっていう。。

$ rails new first_app create create README.rdoc -略- run bundle install /Users/eshinohara/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799: [BUG] Segmentation fault ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10.8.0] -- Control frame information ----------------------------------------------- c:0038 p:---- s:0217 b:0217 l:000216 d:000216 CFUNC :connect

  再度rvmでRubyごと消して、ググったらiconvとopenssl入れれば、、的なのが出てきたので

rvm pkg installでiconvとopenssl入れてやります。 $ rvm pkg install iconv Fetching libiconv-1.13.1.tar.gz to /Users/eshinohara/.rvm/archives % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 4605k 100 4605k 0 0 986k 0 0:00:04 0:00:04 --:--:-- 1275k Extracting libiconv-1.13.1.tar.gz to /Users/eshinohara/.rvm/src Configuring libiconv in /Users/eshinohara/.rvm/src/libiconv-1.13.1. Compiling libiconv in /Users/eshinohara/.rvm/src/libiconv-1.13.1. Installing libiconv to /Users/eshinohara/.rvm/usr $ rvm pkg install openssl Fetching openssl-0.9.8t.tar.gz to /Users/eshinohara/.rvm/archives % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3690k 100 3690k 0 0 473k 0 0:00:07 0:00:07 --:--:-- 532k Extracting openssl-0.9.8t.tar.gz to /Users/eshinohara/.rvm/src Configuring openssl in /Users/eshinohara/.rvm/src/openssl-0.9.8t. Compiling openssl in /Users/eshinohara/.rvm/src/openssl-0.9.8t. Installing openssl to /Users/eshinohara/.rvm/usr

  でもって、もっかいRuby、Gem、Railsときて、 rails newしてやると、、

Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems.org/gems/jquery-rails-2.0.2.gem) An error occured while installing jquery-rails (2.0.2), and Bundler cannot continue. Make sure that `gem install jquery-rails -v '2.0.2'` succeeds before bundling

ここまでハマると、もう何なの?って感じですが…w   gemコマンドを直接叩くと普通に成功するので、なんだかなぁって  ググってくと↓セキュリティフィックスって事みたいです。 http://www.ruby-lang.org/ja/news/2012/04/20/ruby-1-9-3-p194-is-released/ ↓って書いてありましたが、オススメしない方法でその場しのぎしちゃったなど…w RubyGemsSSL証明書をどのように使うかは、~/.gemrcファイルや/etc/gemrcファイルでの :ssl_ca_cert オプションと :ssl_verify_modeオプションで設定することができます。 -略- なお、:ssl_verify_mode を0にしてSSL証明書のチェックをしないようにすることもできますが、 こちらはお勧めしません。   ということで、ようやく↓が出てきてメデタシメデタシ。

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.