【问题标题】:'Failed to build gem native extension' when running bundle install运行捆绑安装时“无法构建 gem 原生扩展”
【发布时间】:2016-10-27 21:36:58
【问题描述】:

当我在我的项目目录中运行“捆绑安装”时,我收到以下错误:

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

    c:/Ruby22/bin/ruby.exe -r ./siteconf20161028-11856-1tljde.rb extconf.rb
checking for CLOCK_MONOTONIC in time.h... yes
checking for clockid_t in time.h... yes
checking for clock_gettime() in -lrt... no
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for poll() in poll.h... no
checking for getaddrinfo() in sys/types.h,sys/socket.h,netdb.h... no
getaddrinfo 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=c:/Ruby22/bin/$(RUBY_BASE_NAME)
        --with-rtlib
        --without-rtlib
        --with-nsllib
        --without-nsllib
        --with-socketlib
        --without-socketlib

extconf failed, exit code 1

Gem files will remain installed in c:/Ruby22/lib/ruby/gems/2.2.0/gems/kgio-2.9.2
for inspection.
Results logged to
c:/Ruby22/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/kgio-2.9.2/gem_make.out

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

这是我的 Gemfile:

source 'https://rubygems.org'

#don't upgrade
gem 'rails', '3.2.11'
gem 'rack', '1.4.0'

ruby '2.2.5'


gem 'rack-attack'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
gem 'foreman'

group :development do
  gem 'brakeman'
  gem 'bundler-audit'
  gem 'guard-brakeman'
  gem 'guard-livereload'
  gem 'guard-rspec'
  gem 'guard-shell'
  gem 'pry'
  gem 'rack-livereload'
  gem 'rb-fsevent'
  gem 'travis-lint'
  gem 'better_errors'
  gem 'binding_of_caller'
end

gem 'gauntlt'

gem 'simplecov', :require => false, :group => :test

group :development, :test do
  gem 'launchy'
  gem 'capybara'
  gem 'database_cleaner'
  gem 'poltergeist'
  gem 'rspec-rails', '2.14.2'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails'
  gem 'coffee-rails'
  gem 'jquery-fileupload-rails'
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
 gem 'bcrypt'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
 gem 'unicorn'

# Pow related gem
gem 'powder'

gem 'aruba'
#gem 'minitest', '~> 4.0', :require=> "minitest/autorun"

#gem 'minitest'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

gem 'execjs'
gem 'therubyracer'

# Add SMTP server support using MailCatcher
gem 'mailcatcher'

我在 Windows 10 上运行 ruby​​ 2.2.5 我不确定 rails 版本是什么,因为我在尝试“rails -v”时遇到错误。我认为这不是我遇到上述错误的原因,因为“rails -v”错误是最近出现的。

【问题讨论】:

    标签: ruby-on-rails ruby rubygems windows-10 bundler


    【解决方案1】:

    您的 Gemfile 中有 gem 'unicorn' 吗?

    Unicorn 需要 kgio 安装失败,我不确定这个 gem 是否适用于 Window。尝试将服务器从 unicorn 更改为 thin - 可以进行开发。

    您还可以在 Gemfile 中指定 gem 的平台

    platforms :ruby do #unux
      gem 'unicorn'
    end
    
    platforms :mswin do
      #gems specific to windows
    end
    

    希望对你有帮助

    【讨论】:

    • 感谢您的回复。我会尝试从独角兽变瘦。但是,是否有可能向我解释更多(也许用外行的话?)你答案的第二部分?我还是个编码新手,我已经遇到了麻烦只是设置才能开始。
    • 在 Gemfile 中,您可以指定为不同平台安装的 gem。如果我在回答中显示 gem unicorn,当您在 UNIX 系统(如 ubuntu 或 MacOS)上运行应用程序时,将安装该应用程序。当您在 Windows 平台上运行 bundle 和应用程序时,将安装 :mswin 块中的 Gems。您可以在此处阅读有关组的一些信息:bundler groups docbundler gemfile groups
    • 好吧,我明白了。另一个菜鸟问题:为什么在我的 gemfile 中找不到 :mswin 块?还是你的意思是我应该自己添加?
    • 你应该添加它
    猜你喜欢
    • 2012-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-28
    • 1970-01-01
    • 1970-01-01
    • 2012-09-15
    • 2014-04-27
    相关资源
    最近更新 更多