soraなりの日々 - fc2 -

こころにひっかかったもの

[ruby19, rails23] CentOS + passenger でコケる件について

次の開発はやっぱ ruby 1.9.1、rails 2.3.2 しょ!
て、ことでいろいろやってたんだけど。。。
やっぱね、新しいものでやろうとするといろいろトラブルわけですわ。
て、ことで centos 5.2、ruby 1.9.1、rails 2.3.2、passenger 2.1.1/2
でハマったことをメモしておく。

このエントリーをはてなブックマークに追加
で、早速新しく centos の 5.2 をセットアップ。
おまじない的な yum install でダーっと入れまくり、
さて、ruby 1.9.1 も rails 2.3.2 の環境もできましたと。
あとはね、ローンチ用の passenger ですね、と。

そいつはいきなりあらわれた。
[root@localhost ~]# rake -V /usr/local/bin/rake:19:in `load': Is a directory - /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.1.2/lib/rake (Errno::EISDIR) from /usr/local/bin/rake:19:in `
'

えっ?あれ??
passenger をインストール後、rake が通らなくなってる。。。

一旦、passenger を削除する。
[root@localhost ~]# gem uninstall passenger
Remove executables:
    passenger-spawn-server, passenger-install-apache2-module, passenger-config, passenger-memory-stats, passenger-make-enterprisey, passenger-status, passenger-stress-test

in addition to the gem? [Yn]  y
Removing passenger-spawn-server
Removing passenger-install-apache2-module
Removing passenger-config
Removing passenger-memory-stats
Removing passenger-make-enterprisey
Removing passenger-status
Removing passenger-stress-test
Successfully uninstalled passenger-2.1.2


で、もっかい。
[root@localhost ~]# rake -V
rake, version 0.8.3


確実に passenger 入れる時ですね、と。
エラー出たからと、--ignore-dependencies で入れたのがあかんかったんやろね。
で、再度 gem install passenger をやってみる。
[root@localhost ~]# gem install passenger
Building native extensions.  This could take a while...
ERROR:  Error installing passenger:
    ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install passenger
creating Makefile

make
gcc -I. -I/usr/local/include/ruby-1.9.1/i686-linux -I/usr/local/include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -D_FILE_OFFSET_BITS=64  -fPIC  -O2 -g -Wall -Wno-parentheses  -o fastthread.o -c fastthread.c
fastthread.c:13:20: error: intern.h: そのようなファイルやディレクトリはありません
fastthread.c:14 から include されたファイル中:
/usr/local/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: 警告: #warning rubysig.h is obsolete
fastthread.c:349: error: static declaration of ‘rb_mutex_locked_p’ follows non-static declaration
/usr/local/include/ruby-1.9.1/ruby/intern.h:707: error: previous declaration of ‘rb_mutex_locked_p’ was here
fastthread.c:366: error: static declaration of ‘rb_mutex_try_lock’ follows non-static declaration
/usr/local/include/ruby-1.9.1/ruby/intern.h:708: error: previous declaration of ‘rb_mutex_try_lock’ was here
fastthread.c: In function ‘lock_mutex’:
fastthread.c:392: error: ‘rb_thread_critical’ undeclared (first use in this function)
fastthread.c:392: error: (Each undeclared identifier is reported only once
fastthread.c:392: error: for each function it appears in.)
fastthread.c: トップレベル:
fastthread.c:406: error: static declaration of ‘rb_mutex_lock’ follows non-static declaration
/usr/local/include/ruby-1.9.1/ruby/intern.h:709: error: previous declaration of ‘rb_mutex_lock’ was here
fastthread.c: In function ‘set_critical’:
fastthread.c:438: error: ‘rb_thread_critical’ undeclared (first use in this function)
fastthread.c: In function ‘unlock_mutex’:
fastthread.c:447: error: ‘rb_thread_critical’ undeclared (first use in this function)
fastthread.c: トップレベル:
fastthread.c:463: error: static declaration of ‘rb_mutex_unlock’ follows non-static declaration
/usr/local/include/ruby-1.9.1/ruby/intern.h:710: error: previous declaration of ‘rb_mutex_unlock’ was here
fastthread.c: In function ‘rb_mutex_exclusive_unlock’:
fastthread.c:499: error: ‘rb_thread_critical’ undeclared (first use in this function)
fastthread.c: トップレベル:
fastthread.c:524: error: conflicting types for ‘rb_mutex_synchronize’
/usr/local/include/ruby-1.9.1/ruby/intern.h:712: error: previous declaration of ‘rb_mutex_synchronize’ was here
fastthread.c: In function ‘wait_condvar’:
fastthread.c:620: error: ‘rb_thread_critical’ undeclared (first use in this function)
fastthread.c:626: 警告: passing argument 1 of ‘rb_ensure’ from incompatible pointer type
fastthread.c: In function ‘rb_condvar_broadcast’:
fastthread.c:684: error: ‘rb_thread_critical’ undeclared (first use in this function)
fastthread.c: In function ‘signal_condvar’:
fastthread.c:703: error: ‘rb_thread_critical’ undeclared (first use in this function)
fastthread.c: In function ‘rb_queue_marshal_load’:
fastthread.c:824: error: ‘struct RArray’ has no member named ‘len’
fastthread.c:828: error: ‘struct RArray’ has no member named ‘ptr’
fastthread.c:828: error: ‘struct RArray’ has no member named ‘len’
fastthread.c: In function ‘Init_fastthread’:
fastthread.c:1182: error: ‘rb_thread_critical’ undeclared (first use in this function)
make: *** [fastthread.o] エラー 1


Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/fastthread-1.0.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/fastthread-1.0.1/ext/fastthread/gem_make.out
Updating class cache with 2263 classes...


やっぱりエラーがでるわな。。。
ruby 1.9 じゃ必要なさげな fastthread でエラーでとるのね。
パッチ当ての方法とかいろいろ試したんだけど、ダメ。

元々のエラーはさ、どうも ruby の load path が passenger 入れることによって
書き変わってるのが原因っぽい(たぶん、--ignore-dependencies の影響)

$: を見てみる。
[root@localhost src]# ruby -e 'puts $:'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.1.1/lib
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.1.1/ext
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.1.1/bin
/usr/local/lib/ruby/gems/1.9.1/gems/activeresource-2.3.2/lib
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.4/bin
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.4/lib
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib
/usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-2.3.2/lib
/usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.2/bin
/usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib
/usr/local/lib/ruby/site_ruby/1.9.1
/usr/local/lib/ruby/site_ruby/1.9.1/i686-linux
/usr/local/lib/ruby/site_ruby
/usr/local/lib/ruby/vendor_ruby/1.9.1
/usr/local/lib/ruby/vendor_ruby/1.9.1/i686-linux
/usr/local/lib/ruby/vendor_ruby
/usr/local/lib/ruby/1.9.1
/usr/local/lib/ruby/1.9.1/i686-linux


あー、やっぱりね。
passenger 側の rake を見るようになってるわ。。。

でも、passenger 動かないと rails 上でアプリ作っても
到底ローンチなんてできないんで無理やっこ動かすように対処。

なので、rake を書き換える。
vi /usr/local/bin/rake

#!/usr/local/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'rake' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
  version = $1
  ARGV.shift
end

gem 'rake', version

$:.delete_if {|x| x == "/usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.1.1/lib" }
$:.delete_if {|x| x == "/usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.1.1/ext" }
$:.delete_if {|x| x == "/usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.1.1/bin" }
load 'rake'


で、うまく passenger 入れることできた。
rails も動いてる。

もっと smart な方法ありそうだけどなー。。。
このエントリーをはてなブックマークに追加

コメント

コメントの投稿


管理者にだけ表示を許可する

トラックバック

トラックバックURLはこちら
http://sora2hs.blog70.fc2.com/tb.php/440-08da4b84
この記事にトラックバックする(FC2ブログユーザー)