Happy My Life

日常とか技術とか

Dapper(x86_64)にscrapiをインストールすると

Dapper(x86_64)で

$ gem install scrapi

でscrapiをインストールして、テストしていると、こんなエラーが

Scraper::Reader::HTMLParseError (Scraper::Reader::HTMLParseError: Unable to load /usr/local/lib/ruby
/gems/1.8/gems/scrapi-1.2.0/lib/scraper/../tidy/libtidy.dylib):
    /usr/local/lib/ruby/gems/1.8/gems/scrapi-1.2.0/lib/scraper/reader.rb:216:in `parse_page'
    /usr/local/lib/ruby/gems/1.8/gems/scrapi-1.2.0/lib/scraper/base.rb:865:in `document'
    /usr/local/lib/ruby/gems/1.8/gems/scrapi-1.2.0/lib/scraper/base.rb:749:in `scrape'

scrapiに付属していたtest caseでも、Unable to Loadで失敗していた。 libtidy.soを強制的に読みこませるようにtidyのソースを書き換えても、結果は同じ。 libtidy.soはちゃんと有るに、うーむ、と悩む。

ググってみると、FreeBSDでscrapiをgemからインストールしても失敗するらしい。 ふと思ったが、gemで配布されているlibtidy.soはLinux x86_32のものではないのか?

ということで、

$ sudo aptitude install libtidy-ruby1.8
$ cd /usr/local/lib/ruby/gems/1.8/gems/scrapi-1.2.0/lib/tidy
$ mv libtidy.so libtidy.so.x86_32
$ ln -s /usr/lib/libtidy.so ./

で、解決した。 これはx86_64環境でgemを使う場合によく起りそうなので、覚えておいて損はないかも。

ちなみに/usr/local/lib/ruby/gems/1.8/gemsなんてpathはないよ、という方

$ gem environment
  - RUBYGEMS VERSION: 1.0.1 (1.0.1)
  - RUBY VERSION: 1.8.6 (2007-06-07 patchlevel 36) [i486-linux]
  - INSTALLATION DIRECTORY: /home/user/lib/ruby/gems/1.8
  ...

INSTALLATION DIRECTORYで表示されているpathにgemがインストールされているので、適時読みかえること。