在雪豹上安装oniguruma宝石的问题

时间:2010-11-05 03:19:52

标签: ruby rvm

我使用的是Snow Leopard 10.6.4,英特尔架构。

我安装了rvm和ruby 1.9.2:

$ rvm list
rvm rubies

=> ruby-1.9.2-p0 [ x86_64 ]

我像这样安装了oniguruma5:

port install oniguruma5

然后,根据常规智慧,我试图像这样安装oniguruma宝石:

sudo gem install oniguruma -- --with-opt-dir=/opt/local

但是我收到编译错误:

Julie:lender bhaupt$ sudo gem install oniguruma -- --with-opt-dir=/opt/local
Building native extensions.  This could take a while...
ERROR:  Error installing oniguruma:
 ERROR: Failed to build gem native extension.

/Users/bhaupt/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb --with-opt-dir=/opt/local
checking for main() in -lonig... yes
creating Makefile

make
gcc -I. -I/Users/bhaupt/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/x86_64-darwin10.4.0 -I/Users/bhaupt/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/backward -I/Users/bhaupt/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -Wall  -o oregexp.o -c oregexp.c
oregexp.c: In function ‘name_callback’:
oregexp.c:111: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness
oregexp.c:111: warning: pointer targets in passing argument 1 of ‘rb_intern2’ differ in signedness
oregexp.c:111: warning: pointer targets in passing argument 1 of ‘rb_intern’ differ in signedness
oregexp.c: In function ‘oregexp_initialize’:
oregexp.c:123: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:124: error: ‘struct RString’ has no member named ‘len’
oregexp.c:138: warning: pointer targets in passing argument 1 of ‘onig_error_code_to_str’ differ in signedness
oregexp.c: In function ‘oregexp_make_match_data’:
oregexp.c:176: warning: passing argument 2 of ‘onig_foreach_name’ from incompatible pointer type
oregexp.c: In function ‘oregexp_match’:
oregexp.c:211: warning: statement with no effect
oregexp.c:215: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:216: error: ‘struct RString’ has no member named ‘len’
oregexp.c:244: warning: pointer targets in passing argument 1 of ‘onig_error_code_to_str’ differ in signedness
oregexp.c: In function ‘oregexp_append_replacement’:
oregexp.c:267: error: ‘struct RString’ has no member named ‘len’
oregexp.c:268: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:277: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:278: error: ‘struct RString’ has no member named ‘len’
oregexp.c:286: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘OnigCodePoint’
oregexp.c:293: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c:297: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c:328: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c:332: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c:336: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c:341: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c:350: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c:371: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c:379: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c:385: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c:392: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c: In function ‘str_mod_check’:
oregexp.c:405: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:405: error: ‘struct RString’ has no member named ‘len’
oregexp.c: In function ‘oregexp_gsub’:
oregexp.c:444: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:445: error: ‘struct RString’ has no member named ‘len’
oregexp.c:462: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c:484: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c:491: warning: pointer targets in passing argument 2 of ‘rb_str_buf_cat’ differ in signedness
oregexp.c: In function ‘oregexp_safe_gsub’:
oregexp.c:527: warning: passing argument 3 of ‘rb_ensure’ from incompatible pointer type
oregexp.c: In function ‘oregexp_scan’:
oregexp.c:614: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:615: error: ‘struct RString’ has no member named ‘len’
oregexp.c: In function ‘oregexp_m_scan’:
oregexp.c:671: warning: passing argument 3 of ‘rb_ensure’ from incompatible pointer type
make: *** [oregexp.o] Error 1


Gem files will remain installed in /Users/bhaupt/.rvm/gems/ruby-1.9.2-p0/gems/oniguruma-1.1.0 for inspection.
Results logged to /Users/bhaupt/.rvm/gems/ruby-1.9.2-p0/gems/oniguruma-1.1.0/ext/gem_make.out

想法?

我确认/opt/local/include包含oniggnu.honigposix.honiguruma.h

5 个答案:

答案 0 :(得分:4)

我的解决方案是最简单的(如果您是mac用户):

brew install oniguruma

答案 1 :(得分:2)

我是Dizan,oniguruma和紫外线的主要开发者,很抱歉花了这么长时间才回答这个问题!

正如Jo Liss所说,oniguruma绑定的目的是提供对一些高级正则表达式功能的访问,这些功能现在已成为Ruby 1.9的标准功能。因此,原则上,1.9上没有必要这样做。

编译1.9的oniguruma绑定,它完全未经测试,所以你或多或少都在你自己,但原则上,很容易修补紫外线和textpow使用1.9中的标准正则表达式。当然这是我的待办事项清单,但不幸的是,现在我几乎没有时间。另一方面,有些人表示有兴趣分叉或接管可以加快速度的项目。我会告诉你这个。

最后一种选择是自己做补丁,这听起来并不像听起来那么令人生畏:据我记忆,你所要做的就是用标准{{1替换所有对ORegexp#new的调用。如果您决定采用这种方式,我很乐意提供帮助,以便在下一版紫外线/文本显示中包含您的补丁。

答案 2 :(得分:1)

(当我尝试在Debian上使用Ruby 1.9安装oniguruma-ruby时遇到同样的问题。)

所以,http://oniguruma.rubyforge.org/说:

  

该库提供了Oniguruma的绑定,Oniguruma是Ruby 1.9标准的正则表达式库。它允许Ruby 1.8的用户访问扩展功能,而无需重新编译或升级Ruby。

听起来不像oniguruma-ruby可以安装在1.9上。

向Dizan提问(我向他发送过这个问题的指针):但即使Oniguruma是Ruby 1.9的标准,如果我想运行一个require 'origuruma'的模块,我仍然需要origuruma-ruby,对吧?所以让它与Ruby 1.9兼容仍然有意义,因为没有其他方法可以获得,例如,在Ruby 1.9上运行Textpow或Ultraviolet - 或者我错过了什么?

答案 3 :(得分:0)

Oniguruma使用紫外线,Ultraviolet使用,Textpow,您将使用Tylenol来排列所有这些依赖项。

一旦排除了所有依赖关系,请确保使用config.gem 'oniguruma', :lib => 'ultraviolet'

包含紫外线库

我稍后会仔细查看该库,我在另一台计算机上,但不包括它对我来说是一个问题。

答案 4 :(得分:0)

我遇到了同样的错误,但我试过了

sudo port install oniguruma

并被告知

Error: Target org.macports.fetch returned: 

        Please use either 
            oniguruma4 (for ruby support) 
        or 
            oniguruma5 (for unicode support)

因为我正在尝试制作红宝石宝石,我安装了oniguruma4而不是oniguruma5 。完成后,除了生成文档时的警告外,gem安装得很干净(没有定义oregexp_initialize)