安装gem capybara-webkit时出错,出现以下错误:Gem :: Ext :: BuildError:错误:无法生成gem本机扩展

问题描述

在安装gemlock文件时,出现以下错误: 我对Ruby很有经验,但是我想做的只是从github运行该应用程序。这是2015年编写的相当古老的程序(https://github.com/jmopr/job-hunter

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

current directory:
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/capybara-webkit-1.15.1
C:/RailsInstaller/Ruby2.3.3/bin/ruby.exe -r ./siteconf20201025-18652-1a6uktj.rb
extconf.rb
Project ERROR: Cannot run compiler 'cl'. Output:
===================
===================
Maybe you forgot to setup the environment?
*** 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:/RailsInstaller/Ruby2.3.3/bin/$(RUBY_BASE_NAME)
        --with-gl-dir
        --without-gl-dir
        --with-gl-include
        --without-gl-include=${gl-dir}/include
        --with-gl-lib
        --without-gl-lib=${gl-dir}/lib
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/lib
Command 'qmake ' Failed

extconf Failed,exit code 1

Gem files will remain installed in
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/capybara-webkit-1.15.1 for
inspection.
Results logged to
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/capybara-webkit-1.15.1/gem_make.out

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

In Gemfile:
  capybara-webkit

该项目的目标是从git hub下载并运行ruby on rails应用程序。这是2015年以来的较旧应用程序,这就是为什么我一直遇到这么多依赖问题的原因。以下是我的gem文件,供您进一步参考。

source 'https://rubygems.org'

#gem 'timeout'
gem 'capybara'
gem 'activerecord-reset-pk-sequence'
gem 'kaminari'
gem 'react-rails'
gem "paperclip"
gem 'dotenv-rails',:groups => [:development,:test]
# Bundle edge Rails instead: gem 'rails',github: 'rails/rails'
gem 'rails','4.2.5.1'
# Use SCSS for stylesheets
gem 'sass-rails','~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier','>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails','~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer',platforms: :ruby

gem 'nokogiri','>= 1.5.0'

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder','~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc','~> 0.4.0',group: :doc

# Use ActiveModel has_secure_password
gem 'bcrypt','~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'
gem 'faraday','~> 0.9.2'
gem 'httparty','~> 0.13.7'
gem 'delayed_job_active_record'
# Use Capistrano for deployment
# gem 'capistrano-rails',group: :development

group :test,:production do
  gem 'pg'
end

group :development,:test do
  gem 'capybara-webkit'
  gem 'selenium'
  gem 'selenium-webdriver'
  gem 'byebug'
  # Use sqlite3 as the database for Active Record
  gem 'sqlite3'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console','~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

``
  
    

解决方法

很高兴知道您使用的是哪个操作系统。如我所见,它的Windows?

在Mac上,您可能必须安装qtwebkit 在Ubuntu Xvfb上可以提供帮助。 但是IDK如何在Windows上处理此问题