[英]Setting up a Ruby On Rails project on windows with nokogiri problems?
I installed Ruby 2.5.1
, I have the IDE RubyMine . 我安装了Ruby 2.5.1
,我有IDE RubyMine 。
I started a new project and my gemfile
looks like this: 我开始了一个新项目,我的gemfile
如下所示:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
gem 'rails', '~> 5.1.0'
When I run the bundle I get this error: 运行捆绑软件时,出现以下错误:
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
I tried following the instructions here , and do gem install nokogiri
and it said that 1 gem was installed
. 我尝试按照此处的说明进行操作 ,并gem install nokogiri
,它说1 gem was installed
了1 gem was installed
。
But then I ran bundle update again, and I got that error again. 但是后来我再次运行了包更新,再次出现了该错误。
I did nokogiri -version
: 我做了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
fyi, it works perfectly on Ubuntu, on the same ruby version and rubymine. fyi,它在Ubuntu,红宝石版本和红宝石上都可以完美运行。 But I can not be bothered to double boot or use a VM everytime So I need this solved somehow. 但是我不必每次都进行双重引导或使用VM,所以我需要以某种方式解决此问题。
If anyone had this issue? 如果有人遇到这个问题?
I faced the same issue around 7-8 months back along with the issues of some other gems. 大约7至8个月后,我遇到了同样的问题,同时还遇到了其他一些宝石。 Couldn't figure out the issue then. 当时无法解决问题。 So eventually had to switch to Linux, so i would you to switch too because if you are going to work on Rails for some time then problems with gems will just keep hitting you. 所以最终不得不切换到Linux,所以我也要切换到Linux,因为如果您打算在Rails上工作一段时间,那么gem的问题将继续打击您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.