2012年5月9日水曜日

install Ruby1.8.7 and RubyGems1.3.7 on CentOS5



※this text from livedoor blog 2009/10/29<br />
<br />



★Ruby1.8.7のRPMのパッケージを作ってインストールする場合

RPMforgeを使う準備
$ sudo rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

checkinstallをインストール
$ sudo yum --enablerepo=rpmforge install checkinstall
$ sudo yum install rpm-build

コンパイルに必要なライブラリをインストール
$ sudo yum install gcc
$ sudo yum install zlib-devel

ruby1.8.7をmake
$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p249.tar.gz
$ tar zxvf ruby-1.8.7-p249.tar.gz
$ cd ruby-1.8.7-p249
$ ./configure --prefix=/usr
$ make

RPM生成
$ sudo /usr/sbin/checkinstall --fstrans=no

~~~~~~~~~~~~~~~

Please choose the packaging method you want to use.
Slackware [S], RPM [R] or Debian [D]? R

~~~~~~~~~~~~~~~

**********************************************************************

Done. The new package has been saved to

/usr/src/redhat/RPMS/i386/ruby-1.8.7-p249-1.i386.rpm
You can install it in your system anytime using:

rpm -i ruby-1.8.7-p249-1.i386.rpm

**********************************************************************

出来たrpmをインストールする
$ sudo rpm -Uvh /usr/src/redhat/RPMS/i386/ruby-1.8.7-p249-1.i386.rpm

rubyのバージョン確認
$ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]




RubyGems1.3.7のRPMのパッケージを作ってインストール

$ wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
$ tar zxvf rubygems-1.3.7.tgz
$ cd rubygems-1.3.7
$ sudo /usr/sbin/checkinstall -R "/usr/bin/ruby setup.rb"

~~~~~~~~~~~~~~~
**********************************************************************

 Done. The new package has been saved to

 /usr/src/redhat/RPMS/i386/rubygems-1.3.7-1.i386.rpm
 You can install it in your system anytime using:

      rpm -i rubygems-1.3.7-1.i386.rpm

**********************************************************************

出来たrpmをインストールする
$ sudo rpm -Uvh /usr/src/redhat/RPMS/i386/rubygems-1.3.7-1.i386.rpm

バージョン確認
$ gem -v
1.3.7


※↓のようにうまく行かないことがある・・・
解決するのは苦労するので、そういう時はrpm作成を諦め、普通にコンパイルしてインストールする事を薦めます


# sudo /usr/sbin/checkinstall -R "/usr/bin/ruby setup.rb"

checkinstall 1.6.0, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.


The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs?  [y]:

Preparing package documentation...OK

Please write a description for the package.
End your description with an empty line or EOF.
>>

**************************************
**** RPM package creation selected ***
**************************************

This package will be built according to these values:

1 -  Summary: [ Package created with checkinstall 1.6.0 ]
2 -  Name:    [ rubygems ]
3 -  Version: [ 1.3.7 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ Applications/System ]
7 -  Architecture: [ i386 ]
8 -  Source location: [ rubygems-1.3.7 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ rubygems ]

Enter a number to change any of them or press ENTER to continue:

Installing with /usr/bin/ruby setup.rb...

========================= Installation results ===========================
./lib/rubygems.rb:840:in `synchronize': thread 0xb7f8f1bc tried to join itself (ThreadError)
        from ./lib/rubygems.rb:840:in `searcher'
        from ./lib/rubygems/custom_require.rb:34:in `require'
        from /usr/lib/ruby/1.8/yaml.rb:10
        from ./lib/rubygems/custom_require.rb:31:in `gem_original_require'
        from ./lib/rubygems/custom_require.rb:31:in `require'
        from ./lib/rubygems/config_file.rb:220:in `load_file'
        from ./lib/rubygems/config_file.rb:168:in `initialize'
        from ./lib/rubygems.rb:385:in `new'
        from ./lib/rubygems.rb:385:in `configuration'
        from ./lib/rubygems.rb:635:in `path'
        from ./lib/rubygems/source_index.rb:68:in `installed_spec_directories'
        from ./lib/rubygems/source_index.rb:58:in `from_installed_gems'
        from ./lib/rubygems.rb:883:in `source_index'
        from ./lib/rubygems/gem_path_searcher.rb:81:in `init_gemspecs'
        from ./lib/rubygems/gem_path_searcher.rb:13:in `initialize'
        from ./lib/rubygems.rb:841:in `new'
        from ./lib/rubygems.rb:841:in `searcher'
        from ./lib/rubygems.rb:840:in `synchronize'
        from ./lib/rubygems.rb:840:in `searcher'
        from ./lib/rubygems.rb:479:in `find_files'
        from ./lib/rubygems.rb:983:in `load_plugins'
        from ./lib/rubygems.rb:1139
        from setup.rb:24:in `require'
        from setup.rb:24

****  Installation failed. Aborting package creation.

Cleaning up...OK

Bye.

★Ruby1.8.7をコンパイルしてインストールする場合

ruby-1.8.7-p299のインストール
# wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p299.tar.gz
# tar zxvf ruby-1.8.7-p299.tar.gz
# cd ruby-1.8.7-p299
# ./configure --prefix=/usr
# make
# make install
# cd ext/zlib
# ruby extconf.rb --with-zlib-include=/usr/include -with-zlib-lib=/usr/lib
# make
# make install
# ruby -v
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux]
# which ruby
/usr/bin/ruby

rubygems-1.3.7のインストール
# wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
# tar zxvf rubygems-1.3.7.tgz
# cd rubygems-1.3.7
# ruby setup.rb
# gem -v
1.3.7