Subscribed unsubscribe Subscribe Subscribe

ruby gnome2 0.90.7(x86-mingw32)でrequire エラーを回避する

ruby

ruby 1.9/1.8いずれでもgtk2をrequireすると以下のようなエラーになる。

環境はruby 1.9.2 p180(ruby installer)でgem installしたもの。

c:\apps\rubydevkit>gem list

*** LOCAL GEMS ***

atk (0.90.7 x86-mingw32)
cairo (1.10.0 x86-mingw32)
gdk_pixbuf2 (0.90.7 x86-mingw32)
glib2 (0.90.7 x86-mingw32)
gtk2 (0.90.7 x86-mingw32)
minitest (1.6.0)
pango (0.90.7 x86-mingw32)
pkg-config (1.0.8)
poppler (0.90.7 x86-mingw32)
rake (0.8.7)
rdoc (2.5.8)
rsvg2 (0.90.7 x86-mingw32)
C:\ruby\bin>ruby -e 'require "gtk2"'
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- gtk2.so (LoadError)
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from C:/ruby/lib/ruby/gems/1.9.1/gems/gtk2-0.90.7-x86-mingw32/lib/gtk2/base.rb:24:in `rescue in <top (required)>
'
        from C:/ruby/lib/ruby/gems/1.9.1/gems/gtk2-0.90.7-x86-mingw32/lib/gtk2/base.rb:20:in `<top (required)>'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from C:/ruby/lib/ruby/gems/1.9.1/gems/gtk2-0.90.7-x86-mingw32/lib/gtk2.rb:11:in `<top (required)>'
        from <internal:lib/rubygems/custom_require>:33:in `require'
        from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from -e:1:in `<main>'

これに対するパッチは以下のようにgdk_pixbuf2を先にrequireすること。

--- C:/ruby/lib/ruby/gems/1.9.1/gems/gtk2-0.90.7-x86-mingw32/lib/gtk2/base.rb.orig	Tue Feb 22 23:17:40 2011
+++ C:/ruby/lib/ruby/gems/1.9.1/gems/gtk2-0.90.7-x86-mingw32/lib/gtk2/base.rb	Tue Feb 22 23:27:44 2011
@@ -12,6 +11,7 @@
 require 'glib2'
 require 'atk'
 require 'pango'
+require 'gdk_pixbuf2'
 
 base_dir = Pathname.new(__FILE__).dirname.dirname.dirname.expand_path
 vendor_dir = base_dir + "vendor" + "local"
@@ -24,7 +24,6 @@
   require "gtk2.so"
 end
 
-require 'gdk_pixbuf2'
 
 module Gdk
   LOG_DOMAIN = "Gdk"