no such file to load -- ferret_ext

好吧,这的确是一个十分诡异的错误,而且,似乎是win下才会有的。

原因是ferret_ext找不到,而你又确实安装了,说明这个ferret_ext.so(就是C编译完后以便ruby调用的库),不在ruby可以找到的lab路径。那么,照这个逻辑可以



[quote]C:\ruby\lib\ruby\gems\1.8\gems\ferret-0.11.5-x86-mswin32\ext[/quote]

下的 ferret_ext.so 文件拷贝到
如下目录

[quote]C:\ruby\lib\ruby\gems\1.8\gems\ferret-0.11.5-x86-mswin32\lib[/quote]


如下测试:

#ferret_test.rb file:

require 'rubygems'
require 'ferret'
include Ferret
index = Index::Index.new(:path => '/opt/search-index')


[quote]>> require 'rubygems'
=> []
>> require 'ferret'
=> []
>> include Ferret
=> Object
>> puts "ferret works!"
ferret works!
=> nil
>> index = Index::Index.new(:path => '/opt/search-index')
=> #<Ferret::Index::Index:0x481591c @qp=nil, @dir=#<Ferret::Store::FSDirectory:0x4814e04>, @default_field=:*, @reader=nil, @mon_owner=nil, @open=true, @close_di
r=true, @id_field=:id, @writer=nil, @options={:path=>"/opt/search-index", :lock_retry_time=>2, :default_field=>:*, :dir=>#<Ferret::Store::FSDirectory:0x4814e04>
, :analyzer=>#<Ferret::Analysis::StandardAnalyzer:0x4814918>}, @mon_waiting_queue=[], @key=nil, @searcher=nil, @default_input_field=:id, @mon_entering_queue=[],
@auto_flush=false, @mon_count=0>[/quote]

然而,如果你是linux或者mac上遇到的类似问题
那么参考这些

[quote]
I had a stock install of Mac OS X Tiger, without developer tools
installed. When I did the "gem install ferret" I ignored the message
that gcc and make could not be found. RubyGems gave the message that
ferret was installed despite the fact that the C extensions were not
compiled and installed. So I got the error "no such file to load --
ferret_ext" when I tried to run ferret. Here's what I did to get ferret
to work:

Found my Mac OS X Tiger install disk and opened the Xcode Tools folder.
Clicked on the XcodeTools.mpkg. Started the install process and stopped
before I clicked the "Upgrade" button. Instead clicked the "Customize"
button and selected only "gcc 4.0" and the Software Development Kits
"Mac OS X SDK" and "BSD SDK" (I'm not developing Mac apps so didn't want
to crowd my disk with extra stuff I won't use). Then clicked "Upgrade."
What you need gets installed as /usr/bin/gcc plus lots more in
/usr/include. Now you can install ferret and it will compile the C
extensions.

First I removed the broken ferret I installed earlier:
$ gem uninstall ferret

I checked that I had gcc:
$ which gcc
/usr/bin/gcc

If you can't find it, check your bash shell path environment with:
$ env
You should have something like
"/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

I checked for the SDK libraries:
$ cd /usr/include
$ ls -lag
(should show lots of ".h" header files)

Then back to my development directory and ran:
$ sudo gem install ferret
Select which gem to install for your platform (powerpc-darwin7.9.0)
1. ferret 0.10.13 (ruby)
...
Building native extensions. This could take a while...
ruby extconf.rb install ferret
creating Makefile
...
(lots of make cruft)
make install
...
make clean
Successfully installed ferret-0.10.13
Installing ri documentation for ferret-0.10.13...
Installing RDoc documentation for ferret-0.10.13...

You can test ferret with this Ruby code in a file "ferret_test.rb"
require 'rubygems'
require 'ferret'
include Ferret
puts "ferret works!"

Try it with:
$ ruby ferret_test.rb
ferret works!


I hope this helps someone else who might be in a similar situation,
especially if they are googling for "no such file to load -- ferret_ext"
or "Mac OS X gem install ferret" or even "installing gcc on mac os x".


[/quote]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值