1

我正在尝试在我的 Windows 机器上安装蒲公英gem,但它一直失败:

C:\Users\William>gem install dandelion --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing dandelion:
ERROR: Failed to build gem native extension.

C:/Ruby22/bin/ruby.exe -r ./siteconf20150623-7568-1ikffjg.rb extconf.rb
checking for gmake... no
checking for make... yes
checking for cmake... yes
checking for pkg-config... yes
-- cmake .. -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_
FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo -G "Unix Makefiles"
-- C:\DevKit\bin/make.exe
checking for main() in -lgit2... *** 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:/Ruby22/bin/$(RUBY_BASE_NAME)
--use-system-libraries
--with-git2-dir
--without-git2-dir
--with-git2-include
--without-git2-include=${git2-dir}/include
--with-git2-lib
--without-git2-lib=${git2-dir}/lib
--with-git2lib
--without-git2lib
C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:541:in `try_link0'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:556:in `try_link'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:735:in `try_func'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:966:in `block in have_library'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:911:in `block in checking_for'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:351:in `block (2 levels) in postpone'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:351:in `block in postpone'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:347:in `postpone'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:910:in `checking_for'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:961:in `have_library'
from extconf.rb:89:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby22/lib/ruby/gems/2.2.0/gems/rugged-0.2
2.1b1 for inspection.
Results logged to C:/Ruby22/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/rug
ged-0.22.1b1/gem_make.out

声明“您必须先安装开发工具”的错误令人头疼。我已经安装了 DevKit。

任何想法如何解决这个错误?

4

1 回答 1

0

这是一个有趣的。我将大胆猜测并说您有一个libgit2位于的版本,C:/Program Files (x86)/libgit2/lib并且该文件夹以某种方式位于您的Path或可能的其他环境变量中。

解决方法是将该文件夹从它可能所在的环境变量中取出。这应该可以rugged正确构建。

问题

gcc试图测试libgit2它看到它可能在C:/Program Files (x86)/libgit2/lib并使用的库时-LC:/Program Files (x86)/libgit2/lib

问题是它没有正确转义,这导致

gcc: error: Files: No such file or directory
gcc: error: (x86)/libgit2/lib: No such file or directory

这实际上也是为什么 Ruby 不能安装在有空格的文件夹中的原因。

作为旁注:我想指出的是,除了常规的 DevKit 之外,您还拥有cmakepkg-config安装在某个地方和您的Path

于 2015-06-24T16:01:58.443 回答