The RSpec Bookの写経環境を作ったのでメモ。
この本で使われているRubyのバージョンは1.8.7。だいぶ古い。
今更1.8.7を使うのもアレなので、今日時点での最新を使う事にします。
ちなみに、本で使われているバージョンは、
- ruby-1.8.7
- rubygems-1.3.7
- rspec-2.0.0
- cucumber-0.9.2
- cucumber-rails-0.3.2
- database_cleaner-0.5.2
- webrat-0.7.2
- selenium-client-1.2.18
- rails-3.0.0
今回インストールした最新バージョンがこれ。
- ruby-1.9.3p125
- rubygems-1.8.11
- rspec-2.9.0
- cucumber-1.1.9
- cucumber-rails-1.3.0
- database_cleaner-0.5.2
- webrat-0.7.2
- selenium-client-1.2.18
- rails-3.2.2
OSはScientific Linux 6.1を使ってます。
cucumber-railsをインストールすると依存関係でnokogiriがインストールされるんだけど、
以下のようなエラーになりました。
Fetching: nokogiri-1.5.2.gem (100%) Building native extensions. This could take a while... ERROR: Error installing cucumber-rails: ERROR: Failed to build gem native extension. /home/matsu/.rbenv/versions/1.9.3-p125/bin/ruby extconf.rb extconf.rb:10: Use RbConfig instead of obsolete and deprecated Config. checking for libxml/parser.h... no ----- libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies. ----- *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/home/matsu/.rbenv/versions/1.9.3-p125/bin/ruby --with-zlib-dir --without-zlib-dir --with-zlib-include --without-zlib-include=${zlib-dir}/include --with-zlib-lib --without-zlib-lib=${zlib-dir}/lib --with-iconv-dir --without-iconv-dir --with-iconv-include --without-iconv-include=${iconv-dir}/include --with-iconv-lib --without-iconv-lib=${iconv-dir}/lib --with-xml2-dir --without-xml2-dir --with-xml2-include --without-xml2-include=${xml2-dir}/include --with-xml2-lib --without-xml2-lib=${xml2-dir}/lib --with-xslt-dir --without-xslt-dir --with-xslt-include --without-xslt-include=${xslt-dir}/include --with-xslt-lib --without-xslt-lib=${xslt-dir}/lib Gem files will remain installed in /home/matsu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.2 for inspection. Results logged to /home/matsu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.2/ext/nokogiri/gem_make.out
libxml2 と libxslt っていうのが必要みたい。
ここを参考にさせてもらいました。
きたももんががきたん。 真・$HOMEに入れたlibxml2を使うようにgem install nokogiriする方法
インストール先は$HOME/usr/localにします。
mkdir -p $HOME/usr/local/src cd $HOME/usr/local/src wget ftp://xmlsoft.org/libxml2/LATEST_LIBXML2 wget ftp://xmlsoft.org/libxml2/LATEST_LIBXSLT tar xvf LATEST_LIBXML2 cd libxml2-2.7.8 ./configure --prefix=$HOME/usr/local make make install cd .. tar xvf LATEST_LIBXSLT cd libxslt-1.1.26 sudo yum install libgcrypt-devel ./configure --prefix=$HOME/usr/local --with-libxml-src=../libxml2-2.7.8 make make install
これでやっとnokogiriがインストール可能な状態に。
gem install nokogiri -- --with-xml2-include=$HOME/usr/local/include/libxml2 --with-xml2-lib=$HOME/usr/local/lib --with-xslt-dir=$HOME/usr/local
これでやっとcucumber-railsがインストール可能な状態に。
gem install cucumber-rails
長かった。。。