如何安装Nokogiri作为Macruby宝石?

时间:2010-05-05 19:32:04

标签: ruby rubygems nokogiri macruby

最新的MacRuby发行说明(v0.6)指出,作者已经设法让这个版本与SQLite和Nokogiri宝石一起工作。但是当我运行sudo macgem install nokogiri时,我收到以下错误:

ERROR:  Error installing nokogiri:

extconf失败:

然后是一堆路径,然后是:

libxml2 is missing.  try 'port install libxml2' or 'yum install libxml2'
/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/lib/ruby/Gems/1.9.0/gems/nokogiri-1.4.1/ext/nokogiri/extconf.rb:1:in `<main>': libxml2 is missing.  try 'port install libxml2' or 'yum install libxml2' (SystemExit)

任何人都知道如何让这个工作?我的平台是Mac OS X 10.6.3。 Nokogiri通常(在普通的旧红宝石1.8.7上安装)安装没有问题。

的进展

好的,我有:

  1. git clone http://github.com/tenderlove/nokogiri.git
  2. cd nokogiri/ext/nokogiri
  3. 然后我用sudo port upgrade --enforce-variants libxml2 +universalsudo port upgrade --enforce-variants libxslt +universal
  4. 重建了macports库
  5. 然后我成功执行了macruby extconf.rb
  6. 然后我前往make
  7. 此时出现错误:

    /usr/bin/gcc -I. -I/opt/local/include/libxml2 -I/opt/local/include/ -I/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include/ruby-1.9.0/universal-darwin10.0 -I/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include/ruby-1.9.0/ruby/backward -I/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include/ruby-1.9.0 -I. -DHAVE_XMLRELAXNGSETPARSERSTRUCTUREDERRORS -DHAVE_XMLRELAXNGSETPARSERSTRUCTUREDERRORS -DHAVE_XMLRELAXNGSETVALIDSTRUCTUREDERRORS -DHAVE_XMLSCHEMASETVALIDSTRUCTUREDERRORS -DHAVE_XMLSCHEMASETPARSERSTRUCTUREDERRORS -I/opt/local/include/ -I/opt/local/include/libxml2 -I/opt/local/include  -fno-common -fexceptions -fno-common -pipe -O3 -g -Wall -Wno-parentheses  -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline -arch i386 -arch x86_64 -o html_document.o -c html_document.c
    In file included from ./html_document.h:4,
                 from html_document.c:1:
    ./nokogiri.h:35:16: error: st.h: No such file or directory
    In file included from ./html_document.h:4,
                 from html_document.c:1:
    ./nokogiri.h:35:16: error: st.h: No such file or directory
    lipo: can't open input file: /var/folders/wU/wUGgoG1JGeKBgwalWLPMAU+++TI/-Tmp-//ccSgAUv5.out (No such file or directory)
    make: *** [html_document.o] Error 1
    

4 个答案:

答案 0 :(得分:1)

我认为你必须从源代码构建,因为只有Nokogiri的头脑符合MacRuby

答案 1 :(得分:1)

我认为你必须将libxml2构建为通用二进制文件。

如果您使用MacPorts,请执行以下命令。

$ sudo port upgrade --enforce-variants libxml2 +universal
$ sudo port upgrade --enforce-variants libxslt +universal
$ sudo port upgrade --enforce-variants sqlite3 +universal

安装失败(x _ x;

$ sudo macgem install nokogiri                   
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
 make failed:

["/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/bin/macruby extconf.rb", "checking for iconv.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include,/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include/libxml2,/usr/include,/usr/include/libxml2... yes\nchecking for libxml/parser.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include,/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include/libxml2,/usr/include,/usr/include/libxml2... yes\nchecking for libxslt/xslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include,/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include/libxml2,/usr/include,/usr/include/libxml2... yes\nchecking for libexslt/exslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include,/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include/libxml2,/usr/include,/usr/include/libxml2... yes\nchecking for xmlParseDoc() in -lxml2... yes\nchecking for xsltParseStylesheetDoc() in -lxslt... yes\nchecking for exsltFuncRegister() in -lexslt... yes\nchecking for xmlRelaxNGSetParserStructuredErrors()... yes\nchecking for xmlRelaxNGSetParserStructuredErrors()... yes\nchecking for xmlRelaxNGSetValidStructuredErrors()... yes\nchecking for xmlSchemaSetValidStructuredErrors()... yes\nchecking for xmlSchemaSetParserStructuredErrors()... yes\ncreating Makefile\n", "make", "/usr/bin/gcc -I. -I/opt/local/include/libxml2 -I/opt/local/include/ -I/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include/ruby-1.9.0/universal-darwin10.0 -I/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include/ruby-1.9.0/ruby/backward -I/Library/Frameworks/MacRuby.framework/Versions/0.6/usr/include/ruby-1.9.0 -I. -DHAVE_XMLRELAXNGSETPARSERSTRUCTUREDERRORS -DHAVE_XMLRELAXNGSETPARSERSTRUCTUREDERRORS -DHAVE_XMLRELAXNGSETVALIDSTRUCTUREDERRORS -DHAVE_XMLSCHEMASETVALIDSTRUCTUREDERRORS -DHAVE_XMLSCHEMASETPARSERSTRUCTUREDERRORS -I/opt/local/include/ -I/opt/local/include/libxml2 -I/opt/local/include  -fno-common -fexceptions -fno-common -pipe -O3 -g -Wall -Wno-parentheses  -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline -arch i386 -arch x86_64 -o html_document.o -c html_document.c\nIn file included from ./nokogiri.h:75,\n                 from ./html_document.h:4,\n                 from html_document.c:1:\n./xml_document.h:5:16: error: st.h: No such file or directory\nIn file included from ./nokogiri.h:75,\n                 from ./html_document.h:4,\n                 from html_document.c:1:\n./xml_document.h:5:16: error: st.h: No such file or directory\nlipo: can't open input file: /var/tmp//cco5nNYw.out (No such file or directory)\nmake: *** [html_document.o] Error 1\n"]

答案 2 :(得分:1)

如果您使用GitHub的源代码,

$ git clone git://github.com/tenderlove/nokogiri.git
$ cd nokogiri/ext/nokogiri/
$ sed -i.bak 's/<st.h>/<ruby\/st.h>/' nokogiri.h

如果你制作了Nokogiri的宝石包,

$ cd ../..
$ sudo gem install hoe
$ sudo gem install rake-compiler
$ sudo gem install racc
$ sudo gem install rexical
$ mkdir ~/.rubyforge; touch ~/.rubyforge/user-config.yml
$ rake gem

以上命令,我使用了系统默认的ruby。 ( “/ USR /斌/红宝石”)

$ cd pkg
$ sudo macgem install nokogiri-1.4.1.gem

答案 3 :(得分:0)

我上传到GitHub,我做了一个包。 http://wiki.github.com/Watson1978/nokogiri-macruby/