在具有nokogiri问题的Windows上设置Ruby On Rails项目?

时间:2018-04-07 22:38:29

标签: ruby-on-rails ruby

我安装了Ruby gemfile,我有IDE RubyMine

我开始了一个新项目,我的source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.5.1' gem 'rails', '~> 5.1.0' 看起来像这样:

Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 12.3.1
Using concurrent-ruby 1.0.5
Using i18n 1.0.0
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.1.6
Using builder 3.2.3
Using erubi 1.7.1
Using mini_portile2 2.3.0
Fetching nokogiri 1.8.2
Installing nokogiri 1.8.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.2/ext/nokogiri
C:/Ruby25-x64/bin/ruby.exe -r ./siteconf20180408-7088-1nltbvj.rb extconf.rb
--use-system-libraries
checking if the C compiler accepts ... yes
Building nokogiri using system libraries.
pkg-config could not be used to find libxml-2.0
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1"

pkg-config could not be used to find libxslt
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1"

pkg-config could not be used to find libexslt
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1"

ERROR: cannot discover where libxml2 is located on your system. please make sure
`pkg-config` is installed.
*** 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=C:/Ruby25-x64/bin/$(RUBY_BASE_NAME)
    --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

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/nokogiri-1.8.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.2 for inspection.
Results logged to
C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/nokogiri-1.8.2/gem_make.out

An error occurred while installing nokogiri (1.8.2), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.8.2'` succeeds before bundling.

In Gemfile:
  rails was resolved to 5.1.6, which depends on
    actioncable was resolved to 5.1.6, which depends on
      actionpack was resolved to 5.1.6, which depends on
        actionview was resolved to 5.1.6, which depends on
          rails-dom-testing was resolved to 2.0.3, which depends on
            nokogiri

当我运行捆绑包时,我收到此错误:

gem install nokogiri

我尝试关注instructions here,并执行1 gem was installed并且说nokogiri -version

然后我再次运行了捆绑更新,我又遇到了这个错误。

我做了C:\Users\Ben\RubymineProjects\untitled1>nokogiri -version # Nokogiri (1.8.2) --- warnings: [] nokogiri: 1.8.2 ruby: version: 2.5.1 platform: x64-mingw32 description: ruby 2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32] engine: ruby libxml: binding: extension source: packaged libxml2_path: "/home/flavorjones/code/oss/nokogiri/ports/x86_64-w64-mingw32/libxml2/2.9.7" libxslt_path: "/home/flavorjones/code/oss/nokogiri/ports/x86_64-w64-mingw32/libxslt/1.1.32" libxml2_patches: [] libxslt_patches: [] compiled: 2.9.7 loaded: 2.9.7

add_widget

fyi,它在Ubuntu上完美运行,在同一个ruby版本和rubymine上。 但是我不能为每次双启动或使用VM而烦恼所以我需要这解决了。

如果有人有这个问题?

1 个答案:

答案 0 :(得分:0)

我在7-8个月左右遇到了同样的问题以及其他一些宝石的问题。然后无法弄清楚问题。因此最终不得不切换到Linux,所以我也要切换,因为如果你打算在Rails上工作一段时间,那么宝石的问题就会一直打击你。