Ruby on rails Nokogiri安装失败,缺少libxslt

Ruby on rails Nokogiri安装失败,缺少libxslt,ruby-on-rails,macos,nokogiri,Ruby On Rails,Macos,Nokogiri,我很抱歉,但我想我尝试了我在互联网上看到的一切,以使其工作,但它总是失败:( 我必须在一个使用ruby 2.1.10的旧rails项目上工作,当我捆绑更新nokogiri'1.6.3.1'构建时失败 它与ruby 2.6.6和nokogiri-1.10.10配合得很好 我已经安装了libxml2和libxsl,并安装了自制xcode,我已经阅读并同意了许可证 我试着安装nokogiri链接 gem install nokogiri-v'1.6.3.1'--使用系统库--with-xml2-inc

我很抱歉,但我想我尝试了我在互联网上看到的一切,以使其工作,但它总是失败:(

我必须在一个使用ruby 2.1.10的旧rails项目上工作,当我捆绑更新nokogiri'1.6.3.1'构建时失败

它与ruby 2.6.6和nokogiri-1.10.10配合得很好

我已经安装了libxml2和libxsl,并安装了自制xcode,我已经阅读并同意了许可证

我试着安装nokogiri链接
gem install nokogiri-v'1.6.3.1'--使用系统库--with-xml2-include=$(brew--前缀libxml2)/include/libxml2--with xslt include=$(brew--前缀libxslt)/include/libxslt

这就是输出

Building native extensions with: '--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --with-xslt-include=/usr/local/opt/libxslt/include/libxslt'
This could take a while...
Building nokogiri using system libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/lokhi/.rbenv/versions/2.1.10/bin/ruby extconf.rb --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --with-xslt-include=/usr/local/opt/libxslt/include/libxslt
Building nokogiri using system libraries.
libxml2 version 2.9.0 and later is not yet supported, but proceeding anyway.
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... no
checking for xsltParseStylesheetDoc() in -lxslt... no
checking for xsltParseStylesheetDoc() in -llibxslt... no
-----
libxslt is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/lokhi/.rbenv/versions/2.1.10/bin/ruby
    --help
    --clean
    --use-system-libraries
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-xslt-dir
    --without-xslt-dir
    --with-xslt-include=${xslt-dir}/include
    --with-xslt-lib
    --without-xslt-lib=${xslt-dir}/lib
    --with-exslt-dir
    --without-exslt-dir
    --with-exslt-include
    --without-exslt-include=${exslt-dir}/include
    --with-exslt-lib
    --without-exslt-lib=${exslt-dir}/lib
    --with-libexslt-config
    --without-libexslt-config
    --with-pkg-config
    --without-pkg-config
    --with-xsltlib
    --without-xsltlib
    --with-libxsltlib
    --without-libxsltlib

extconf failed, exit code 1

Gem files will remain installed in /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3.1 for inspection.
Results logged to /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-19/2.1.0-static/nokogiri-1.6.3.1/gem_make.out
我什么也没试过
gem安装nokogiri-v'1.6.3.1'

Building native extensions.  This could take a while...
Building nokogiri using packaged libraries.
ERROR:  Error installing nokogiri:
   ERROR: Failed to build gem native extension.

   /Users/lokhi/.rbenv/versions/2.1.10/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
   --with-opt-dir
   --without-opt-dir
   --with-opt-include
   --without-opt-include=${opt-dir}/include
   --with-opt-lib
   --without-opt-lib=${opt-dir}/lib
   --with-make-prog
   --without-make-prog
   --srcdir=.
   --curdir
   --ruby=/Users/lokhi/.rbenv/versions/2.1.10/bin/ruby
   --help
   --clean
   --use-system-libraries
   --enable-static
   --disable-static
   --with-zlib-dir
   --without-zlib-dir
   --with-zlib-include
   --without-zlib-include=${zlib-dir}/include
   --with-zlib-lib
   --without-zlib-lib=${zlib-dir}/lib
   --enable-cross-build
   --disable-cross-build

extconf failed, exit code 1

Gem files will remain installed in /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3.1 for inspection.
Results logged to /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-19/2.1.0-static/nokogiri-1.6.3.1/gem_make.out
而且只有
gem安装nokogiri-v'1.6.3.1'--使用系统库

Building native extensions with: '--use-system-libraries'
This could take a while...
Building nokogiri using system libraries.
ERROR:  Error installing nokogiri:
   ERROR: Failed to build gem native extension.

   /Users/lokhi/.rbenv/versions/2.1.10/bin/ruby extconf.rb --use-system-libraries
Building nokogiri using system libraries.
libxml2 version 2.9.0 and later is not yet supported, but proceeding anyway.
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... no
checking for xsltParseStylesheetDoc() in -lxslt... no
checking for xsltParseStylesheetDoc() in -llibxslt... no
-----
libxslt is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
   --with-opt-dir
   --without-opt-dir
   --with-opt-include
   --without-opt-include=${opt-dir}/include
   --with-opt-lib
   --without-opt-lib=${opt-dir}/lib
   --with-make-prog
   --without-make-prog
   --srcdir=.
   --curdir
   --ruby=/Users/lokhi/.rbenv/versions/2.1.10/bin/ruby
   --help
   --clean
   --use-system-libraries
   --with-zlib-dir
   --without-zlib-dir
   --with-zlib-include
   --without-zlib-include=${zlib-dir}/include
   --with-zlib-lib
   --without-zlib-lib=${zlib-dir}/lib
   --with-xml2-dir
   --without-xml2-dir
   --with-xml2-include
   --without-xml2-include=${xml2-dir}/include
   --with-xml2-lib
   --without-xml2-lib=${xml2-dir}/lib
   --with-libxml-2.0-config
   --without-libxml-2.0-config
   --with-pkg-config
   --without-pkg-config
   --with-xslt-dir
   --without-xslt-dir
   --with-xslt-include
   --without-xslt-include=${xslt-dir}/include
   --with-xslt-lib
   --without-xslt-lib=${xslt-dir}/lib
   --with-libxslt-config
   --without-libxslt-config
   --with-exslt-dir
   --without-exslt-dir
   --with-exslt-include
   --without-exslt-include=${exslt-dir}/include
   --with-exslt-lib
   --without-exslt-lib=${exslt-dir}/lib
   --with-libexslt-config
   --without-libexslt-config
   --with-xsltlib
   --without-xsltlib
   --with-libxsltlib
   --without-libxsltlib

extconf failed, exit code 1

Gem files will remain installed in /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3.1 for inspection.
Results logged to /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-19/2.1.0-static/nokogiri-1.6.3.1/gem_make.out
有关我的系统的更多信息
clangg-v

Apple clang version 12.0.0 (clang-1200.0.32.27)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
我不知道现在该怎么办你有什么想法吗

谢谢

编辑并添加新信息

ls /usr/local/share/aclocal/
和mkmf.log的输出

              _Nonnull
conftest.c:15:15: error: implicit declaration of function 'xsltParseStylesheetDoc' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
int t(void) { xsltParseStylesheetDoc(); return 0; }
              ^
194 warnings and 1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: #include <libxslt/xslt.h>
 4:
 5: /*top*/
 6: extern int t(void);
 7: int main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     printf("%p", &t);
11:   }
12:
13:   return 0;
14: }
15: int t(void) { xsltParseStylesheetDoc(); return 0; }
/* end */

mkmf.log的输出完全相同。我看到您已经安装了libxml2,也尝试安装libxslt、libxslt-devel,我认为在某个点上还存在对openssl-devel的依赖性。

编辑

Nokogiri有一个关于在MacOS上安装的教程:

你能试试那个文件中的步骤吗

旧信息:

根据:

或者可能:

ln -s /usr/local/opt/libxml2/share/aclocal/libxml.m4 /usr/local/share/aclocal/libxml.m4

假设您正在使用MacOs,是否可以尝试以下操作:不,它不起作用:(我有相同的错误消息
libxml2 2.9.0版和更高版本尚不受支持,但仍在继续。
…您的libxml2版本太新了!:(你能试着安装一个旧版本吗?我已经将libxml2降级到2.7.2了。我一直认为libxslt丢失了,但不再有关于libxml2.9.0的警告。现在你已经降级了,你能在我的回答中遵循nokogiri Macos教程吗?我也有同样的错误。你能
ls/usr/local/share/aclocal/
看看还有其他错误吗文件,还有
ls/usr/local/opt/libxml2/share/aclocal/
,看看是否有丢失的xml文件,您可能也想链接这些文件?我编辑了这篇文章,添加了关于ls的新信息。这两个目录在nokogiri网站上用一个更好、更有用的文档更新了我的答案,希望它能提供您需要的步骤谢谢,我已经测试了所有列表,但libxslt总是出现相同的错误:(
libxml.m4
cat /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-19/2.1.0-static/nokogiri-1.6.3.1/gem_make.out
/Users/lokhi/.rbenv/versions/2.1.10/bin/ruby extconf.rb --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --with-xslt-include=/usr/local/opt/libxslt/include/libxslt
Building nokogiri using system libraries.
libxml2 version 2.9.0 and later is not yet supported, but proceeding anyway.
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... no
checking for xsltParseStylesheetDoc() in -lxslt... no
checking for xsltParseStylesheetDoc() in -llibxslt... no
-----
libxslt is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/lokhi/.rbenv/versions/2.1.10/bin/ruby
    --help
    --clean
    --use-system-libraries
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-xslt-dir
    --without-xslt-dir
    --with-xslt-include=${xslt-dir}/include
    --with-xslt-lib
    --without-xslt-lib=${xslt-dir}/lib
    --with-exslt-dir
    --without-exslt-dir
    --with-exslt-include
    --without-exslt-include=${exslt-dir}/include
    --with-exslt-lib
    --without-exslt-lib=${exslt-dir}/lib
    --with-libexslt-config
    --without-libexslt-config
    --with-pkg-config
    --without-pkg-config
    --with-xsltlib
    --without-xsltlib
    --with-libxsltlib
    --without-libxsltlib

extconf failed, exit code 1
              _Nonnull
conftest.c:15:15: error: implicit declaration of function 'xsltParseStylesheetDoc' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
int t(void) { xsltParseStylesheetDoc(); return 0; }
              ^
194 warnings and 1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: #include <libxslt/xslt.h>
 4:
 5: /*top*/
 6: extern int t(void);
 7: int main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     printf("%p", &t);
11:   }
12:
13:   return 0;
14: }
15: int t(void) { xsltParseStylesheetDoc(); return 0; }
/* end */
This could take a while...
Building nokogiri using system libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/lokhi/.rbenv/versions/2.1.10/bin/ruby extconf.rb --use-system-libraries
Building nokogiri using system libraries.
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... no
checking for xsltParseStylesheetDoc() in -lxslt... no
checking for xsltParseStylesheetDoc() in -llibxslt... no
-----
libxslt is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/lokhi/.rbenv/versions/2.1.10/bin/ruby
    --help
    --clean
    --use-system-libraries
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include
    --without-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-libxml-2.0-config
    --without-libxml-2.0-config
    --with-pkg-config
    --without-pkg-config
    --with-xslt-dir
    --without-xslt-dir
    --with-xslt-include
    --without-xslt-include=${xslt-dir}/include
    --with-xslt-lib
    --without-xslt-lib=${xslt-dir}/lib
    --with-libxslt-config
    --without-libxslt-config
    --with-exslt-dir
    --without-exslt-dir
    --with-exslt-include
    --without-exslt-include=${exslt-dir}/include
    --with-exslt-lib
    --without-exslt-lib=${exslt-dir}/lib
    --with-libexslt-config
    --without-libexslt-config
    --with-xsltlib
    --without-xsltlib
    --with-libxsltlib
    --without-libxsltlib

extconf failed, exit code 1

Gem files will remain installed in /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3.1 for inspection.
Results logged to /Users/lokhi/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-19/2.1.0-static/nokogiri-1.6.3.1/gem_make.out
brew link --force libxml2
ln -s /usr/local/opt/libxml2/share/aclocal/libxml.m4 /usr/local/share/aclocal/libxml.m4