Rails broken - bundle not working - ovirt-engine-sdk - ERROR: Failed to build gem native extension. Cloud9 AWS

Rails broken - bundle not working - ovirt-engine-sdk - ERROR: Failed to build gem native extension. Cloud9 AWS

我正在 AWS Cloud9 环境中完成由 Michael Hartl 编写的 Ruby Rails 教程 (Rails5)。我现在正在完成第11章。 (也是编程新手)

看来我破坏了一些与 Rails(或 Ruby)系统相关的东西。我无法再启动 Rails 服务器、测试或控制台。

我收到的错误消息通常以此开头,我没有运气在这里或通过 Google 找到太多信息。 ovirt-engine-sdk -v '4.2.3'

/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/spec_set.rb:88:in `block in materialize': Could not find ovirt-engine-sdk-4.2.3 in any of the sources (Bundler::GemNotFound)

尝试 bundle installbundle update 我得到这样的输出:

The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies......
Using rake 12.3.1
Using CFPropertyList 2.3.6
Using concurrent-ruby 1.0.5
Using i18n 0.9.5
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.1.4
Using builder 3.2.3
Using erubi 1.7.1
Using mini_portile2 2.3.0
Using nokogiri 1.8.2
Using rails-dom-testing 2.0.3
Using crass 1.0.4 (was 1.0.3)
Using loofah 2.2.2
Using rails-html-sanitizer 1.0.4
Using actionview 5.1.4
Using rack 2.0.4
Using rack-test 1.0.0
Using actionpack 5.1.4
Using nio4r 2.3.0
Using websocket-extensions 0.1.3
Using websocket-driver 0.6.5
Using actioncable 5.1.4
Using globalid 0.4.1
Using activejob 5.1.4
Using mini_mime 1.0.0
Using mail 2.7.0
Using actionmailer 5.1.4
Using activemodel 5.1.4
Using arel 8.0.0
Using activerecord 5.1.4
Using ansi 1.5.0
Using execjs 2.7.0
Using autoprefixer-rails 8.2.0
Using bcrypt 3.1.11
Using bindex 0.5.0
Using rb-fsevent 0.10.3
Using ffi 1.9.23
Using rb-inotify 0.9.10
Using sass-listen 4.0.0
Using sass 3.5.6
Using bootstrap-sass 3.3.7
Using will_paginate 3.1.6
Using bootstrap-will_paginate 1.0.0
Using bundler 1.16.1
Using byebug 9.0.6
Using mime-types-data 3.2016.0521
Using mime-types 3.1
Using carrierwave 1.2.2
Using coderay 1.1.2
Using coffee-script-source 1.12.2
Using coffee-script 2.4.1
Using method_source 0.9.0
Using thor 0.20.0
Using railties 5.1.4
Using coffee-rails 4.2.2
Using unf_ext 0.0.7.5
Using unf 0.1.4
Using domain_name 0.5.20170404
Using excon 0.62.0
Using faker 1.7.3
Using fission 0.5.0
Using formatador 0.2.5
Using fog-core 1.45.0
Using multi_json 1.13.1
Using fog-json 1.0.2
Using ipaddress 0.8.3
Using xml-simple 1.1.5
Using fog-aliyun 0.2.0
Using fog-xml 0.1.3
Using fog-atmos 0.1.0
Using fog-aws 2.0.1
Using inflecto 0.0.2
Using fog-brightbox 0.14.0
Using fog-cloudatcost 0.1.2
Using fog-digitalocean 0.3.0
Using fog-dnsimple 1.0.0
Using fog-dynect 0.0.3
Using fog-ecloud 0.3.0
Using fog-google 0.1.0
Using fog-internet-archive 0.0.1
Using fog-joyent 0.0.1
Using fog-local 0.5.0
Using fog-openstack 0.1.25
Using json 2.1.0
Fetching ovirt-engine-sdk 4.2.3
Installing ovirt-engine-sdk 4.2.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/local/rvm/gems/ruby-2.4.1/gems/ovirt-engine-sdk-4.2.3/ext/ovirtsdk4c
/usr/local/rvm/rubies/ruby-2.4.1/bin/ruby -r ./siteconf20180409-4891-qfsq17.rb extconf.rb
checking for xml2-config... yes
checking for curl-config... no
*** 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=/usr/local/rvm/rubies/ruby-2.4.1/bin/$(RUBY_BASE_NAME)
        --with-libcurl-config
        --without-libcurl-config
        --with-pkg-config
        --without-pkg-config
extconf.rb:40:in `<main>': The "libcurl" package isn't available. (RuntimeError)

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

  /usr/local/rvm/gems/ruby-2.4.1/extensions/x86_64-linux/2.4.0/ovirt-engine-sdk-4.2.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.4.1/gems/ovirt-engine-sdk-4.2.3 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.4.1/extensions/x86_64-linux/2.4.0/ovirt-engine-sdk-4.2.3/gem_make.out

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

In Gemfile:
  fog was resolved to 1.42.0, which depends on
    fog-ovirt was resolved to 1.0.2, which depends on
      ovirt-engine-sdk

查看上述输出的 gem_make.out 文件结果显示:

current directory: /usr/local/rvm/gems/ruby-2.4.1/gems/ovirt-engine-sdk-4.2.3/ext/ovirtsdk4c
/usr/local/rvm/rubies/ruby-2.4.1/bin/ruby -r ./siteconf20180409-4891-qfsq17.rb extconf.rb
checking for xml2-config... yes
checking for curl-config... no
*** 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=/usr/local/rvm/rubies/ruby-2.4.1/bin/$(RUBY_BASE_NAME)
        --with-libcurl-config
        --without-libcurl-config
        --with-pkg-config
        --without-pkg-config
extconf.rb:40:in `<main>': The "libcurl" package isn't available. (RuntimeError)

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

  /usr/local/rvm/gems/ruby-2.4.1/extensions/x86_64-linux/2.4.0/ovirt-engine-sdk-4.2.3/mkmf.log

extconf failed, exit code 1

上面提到的mkmf.log的输出是:

find_executable: checking for xml2-config... -------------------- yes

--------------------

find_executable: checking for curl-config... -------------------- no

--------------------

"pkg-config --exists libcurl"
package configuration for libcurl is not found

所以我卡住了..此时我无法安装 ovirt-engine-sdk-4.23

在此先感谢您的帮助。如果您需要帮助任何其他文件或信息,请告诉我。

所以我能够通过以下方式解决此问题:

  1. 正在安装 libcurl 开发者版本:

    sudo yum install libcurl libcurl-devel

一旦完成,我 运行 捆绑更新现在在安装中进一步进行 - 此时失败 Installing pg 0.20.0 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

  1. 运行 sudo yum install postgresql-devel 解决了 pg 0.20.0 问题,我现在可以完成捆绑包更新并且 rails 似乎又可以工作了。

  2. Rails 服务器在所有这些之后启动时出现问题。这个命令让它再次工作:bin/rails db:migrate RAILS_ENV=development

在那之后,环境和 rails 一切似乎又恢复正常了。

ubuntu 位用户:

sudo apt-get install build-essential libcurl4-openssl-dev

编辑:

对于 fedora 用户:(我的是 Fedora 32)

sudo dnf install libcurl libcurl-devel

如果 libcurl 已经存在,只需:

sudo dnf install libcurl-devel

可以通过以下方式检查安装:

dnf list installed libcurldnf list installed libcurl-devel

如果您使用的是 Ubuntu 系统,请使用以下命令:

sudo apt-get --assume-yes install gcc libcurl4-openssl-dev libxml2-dev ruby ruby-dev

然后 运行

bundle install

您可以在 linux/debian 或 ubuntu 上通过 运行 以下命令轻松解决此问题:

sudo apt-get install build-essential libcurl4-openssl-dev
sudo apt-get install libxml2-dev

你应该没事的。

我运行遇到了类似的问题:

In Gemfile:
  fog was resolved to 2.1.0, which depends on
    fog-ovirt was resolved to 1.1.6, which depends on
      ovirt-engine-sdk

ovirt 4.3.0 抛出以下错误:

Fetching ovirt-engine-sdk 4.3.0
Installing ovirt-engine-sdk 4.3.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/local/rvm/gems/ruby-2.4.1/gems/ovirt-engine-sdk-4.3.0/ext/ovirtsdk4c
/usr/local/rvm/rubies/ruby-2.4.1/bin/ruby -r ./siteconf20190508-5580-eyxazz.rb extconf.rb
checking for xml2-config... no
*** extconf.rb failed ***

然后我能够在 运行:

之后成功捆绑安装
sudo yum install libxml2 libxml2-devel

但是,sudo yum install libxml2 libxml2-dev 没有成功

Ubuntu 19.04(迪斯科野狗)
首先,找到 mkmf.log 文件并检查导致错误的原因。 如果记录了类似此消息的内容:"libxml2" 包不可用。 前往 here, choose the right version which should take you to a page like this , for libxml2-dev for example, follow the instructions in the Install Howto。 运行bundle install之后应该就成功了