Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 诺科吉里';未能生成gem本机扩展';当我运行bundle安装时_Ruby On Rails_Rubygems_Bundle_Nokogiri - Fatal编程技术网

Ruby on rails 诺科吉里';未能生成gem本机扩展';当我运行bundle安装时

Ruby on rails 诺科吉里';未能生成gem本机扩展';当我运行bundle安装时,ruby-on-rails,rubygems,bundle,nokogiri,Ruby On Rails,Rubygems,Bundle,Nokogiri,我正在运行bundle安装,出现以下错误: Building nokogiri using system libraries. Gem::Ext::BuildError: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --use-system-libraries Building no

我正在运行
bundle安装
,出现以下错误:

Building nokogiri using system libraries.

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --use-system-libraries
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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-pkg-config
    --without-pkg-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-pkg-config
    --without-pkg-config

extconf failed, exit code 1

Gem files will remain installed in /Users/myuser/projectpath/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.2.rc2 for inspection.
Results logged to /Users/myuser/projectpath/vendor/bundle/ruby/2.0.0/extensions/universal-darwin-13/2.0.0/nokogiri-1.6.2.rc2/gem_make.out
An error occurred while installing nokogiri (1.6.2.rc2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.rc2'` succeeds before bundling.
你知道这是什么吗

编辑:
我还安装了nokogiri,奇怪的是gem安装成功了。当我运行
gem list
时,我有
nokogiri(1.6.2.1)
,但当运行
bundle install
时,它会显示错误。

我在安装nokogiri时也遇到一些问题,我安装了以下软件包,它对我有效:

libxslt-dev
libxml2-dev
libruby1.8
libreadline-ruby1.8
libopenssl-ruby
libxml2
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
gem install nokogiri -- --use-system-libraries

我不确定到底需要哪一个。

错误表明您的libxml2系统库已过期。您需要2.6.21或更高版本

在我的Debian/ubuntu系统上,nokogiri为我编译,我可以看到我的版本是2.9.1

dpkg -l | grep libxml2-dev
ii  libxml2-dev:amd64                      2.9.1+dfsg1-3                      amd64        Development files for the GNOME XML library
你有三个选择

  • 检查操作系统包管理器是否提供了更新版本的libxml2 图书馆

  • 下载最新的libxml2源代码,编译并安装 它

  • 在文件中手动指定旧版本的nokogiri 这适用于旧的libxml2库。nokogiri变更日志显示,nokogiri版本1.4.7不会出现此问题(尽管使用的是旧版本) 版本可能使您面临安全问题)
  • 对于解决方案#3,您可以将其放入您的GEM文件中:
    gem'nokogiri',1.4.7'

    在Mavericks上,这个变通方法对我很有效:

    libxslt-dev
    libxml2-dev
    libruby1.8
    libreadline-ruby1.8
    libopenssl-ruby
    libxml2
    
    gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
    
    gem install nokogiri -- --use-system-libraries
    
    请参阅:

    。请参阅此链接并安装nokogiri所需的依赖项。然后运行这个

    • bundle config build.nokogiri--使用系统库
    • bundle安装
    这给了我让Nokogiri 1.6.2安装所需的技巧:

    My ~/.gitconfig具有设置
    autocrlf=input
    。当我删除此设置时,nokogiri构建成功


    在AmazonLinux上,我必须安装这两个devel库,然后为libxml2指定包含路径

    $ yum install libxml2-devel libxslt-devel
    $ gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/usr/include/libxml2/
    

    以前的建议对我没有帮助,以下是OS 10.9的解决方案:

    brew install libxml2
    bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2"
    bundle install
    

    在约塞米蒂10.10上,这个变通方法对我很有效:

    libxslt-dev
    libxml2-dev
    libruby1.8
    libreadline-ruby1.8
    libopenssl-ruby
    libxml2
    
    gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
    
    gem install nokogiri -- --use-system-libraries
    

    在约塞米蒂10.10.1上,此步骤没有帮助(可能对其他人有效)

    基本上,我的本地服务器上的问题是由于
    libxml2
    ,所以下面的解决方法解决了这个问题

    bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2
    
    bundle install
    

    在约塞米蒂10.10上,以下步骤完全解决了我的问题:

    • sudo xcode选择-开关/库/开发人员/命令行工具
    • gem卸载nokogiri libxml ruby
    • gem安装nokogiri
    对于#CentOS,我需要做以下工作:

    gem update --system
    yum install libxml2-devel libxslt-devel ruby-devel
    gem install nokogiri -- --use-system-libraries
    

    这对OS X El Capitan有效:

    brew install libxml2 libxslt libiconv 
    
    运行“brew安装libxml2 libxslt libiconv”后,您可能会发现它们已经安装。别担心,再检查一次也不会有什么坏处

    如果需要,请更改nokogiri的版本。e、 g

    sudo gem install nokogiri -v '1.6.5' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib
    

    对于mac来说,失败的原因是您没有最新的Xcode开发工具。Nokogiri已经用libxml2打包。由于缺乏最新的Xcode开发工具,它无法构建本机扩展

    要更新Xcode开发人员工具,请使用:

    xcode-select --install
    
    然后:

    gem install nokogiri
    
    如果您使用

    gem install nokogiri -- --use-system-libraries
    
    以后可能会收到类似的警告:

    WARNING: Nokogiri was built against LibXML version 2.9.3, but has dynamically loaded 2.9.0
    

    这是一个旧的线程,但我遇到了类似的问题,我的案例中的解决方案与目前发布的完全不同

    经过一番挖掘,我发现了这根线:

    它谈到bundler使用与gem不同的ruby版本

    从OP的粘贴中,我们可以看到bundler正在使用ruby的Mac系统副本:
    
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/Ruby
    

    在我的例子中,我发现gem来自brew
    哪个gem
    给出了
    /usr/local/bin/gem
    哪个符号链接到
    /ceral/ruby/2.3.3/bin/gem
    。我猜OP的案子也一样

    因此,gem和bundler不是在同一个ruby安装上工作的,这解释了OP为什么会看到这样的情况:

    当我运行gem list时,我有nokogiri(1.6.2.1),但当运行bundle install时,它会显示错误

    在我的例子中,我只是简单地运行了
    gem安装bundler
    ,这使得bundler开始使用brew版本的ruby,所有问题都消失了。

    在OSX 10.12(Sierra)上,这对我来说很有效:

    libxslt-dev
    libxml2-dev
    libruby1.8
    libreadline-ruby1.8
    libopenssl-ruby
    libxml2
    
    gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
    
    gem install nokogiri -- --use-system-libraries
    
    gem install nokogiri--use system libraries=true--with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2
    

    我遇到了这个问题。我在mac上运行rails环境。在我从约塞米蒂升级到塞拉之后,我相信这就是它的开始

    为了解决这个问题,我只需安装
    xcode命令行工具
    。我不知道Sierra升级是否删除了它们

    xcode选择--安装

    (这将安装
    xcode命令行工具


    还有另一个症状..git状态之类的东西不起作用。在此之后,我可以使用rails新的appname,一切正常。

    这可以通过安装libxml2来解决:

    brew install libxml2
    bundle config build.nokogiri --use-system-libraries
    bundle install
    

    这是macOS的一个问题,我尝试了上面的所有方法,但都没有效果,所以尝试安装
    libxml2
    的版本,但一切都是徒劳的

    因此,使用下面的命令,您将处于良好状态

    sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
    

    实际上我有最新版本的libxml2(2.9.1),这就是wierd@FabKremer您是否也安装了“-dev”软件包?假设你有Debian/Ubuntu,试试sudo apt get install libxml2 dev@FabKremer,在我看来你在使用Mac。在这种情况下,请阅读这里关于如何安装最新软件包的内容:是的,我正在使用mac。请看我的编辑!我已经安装了nokogiri,在系统中安装了gem,但是在我的项目上进行捆绑安装时,错误仍然存在。请叫我傻瓜,但是nokogiri说你需要2.6.21之后的版本,而你有2.9.1,那么为什么它会抱怨呢?我有2.7.8,看到了同样的问题。Nokogiri应该很好,就像我一样