首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >包安装失败,原因是: Gem::Ext::BuildError: ERROR: FailableBuild原生扩展

问包安装失败,原因是: Gem::Ext::BuildError: ERROR: FailableBuild原生扩展
EN

Stack Overflow用户
提问于 2022-10-31 15:27:33
回答 2查看 206关注 0票数 0

我是红宝石语言的新手,我正在尝试运行一个现有的rails项目。当我试图运行bundle install时,它失败了,出现了以下错误。

代码语言:javascript
复制
Fetching mysql2 0.4.6
Installing mysql2 0.4.6 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/vince/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/mysql2-0.4.6/ext/mysql2
/home/vince/.rbenv/versions/2.7.6/bin/ruby -I /home/vince/.rbenv/versions/2.7.6/lib/ruby/2.7.0 -r ./siteconf20221031-7332-kotkbi.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for rb_big_cmp()... yes
*** 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=/home/vince/.rbenv/versions/2.7.6/bin/$(RUBY_BASE_NAME)
        --with-ruby-dir
        --without-ruby-dir
        --with-ruby-include
        --without-ruby-include=${ruby-dir}/include
        --with-ruby-lib
        --without-ruby-lib=${ruby-dir}/lib
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysql-config
        --without-mysql-config
        --with-mysqlclient-dir
        --without-mysqlclient-dir
        --with-mysqlclient-include
        --without-mysqlclient-include=${mysqlclient-dir}/include
        --with-mysqlclient-lib
        --without-mysqlclient-lib=${mysqlclient-dir}/lib
        --with-mysqlclientlib
        --without-mysqlclientlib
/home/vince/.rbenv/versions/2.7.6/lib/ruby/2.7.0/mkmf.rb:1050:in `block in find_library': undefined method `split' for nil:NilClass (NoMethodError)
        from /home/vince/.rbenv/versions/2.7.6/lib/ruby/2.7.0/mkmf.rb:1050:in `collect'
        from /home/vince/.rbenv/versions/2.7.6/lib/ruby/2.7.0/mkmf.rb:1050:in `find_library'
        from extconf.rb:95:in `<main>'

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

  /home/vince/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/mysql2-0.4.6/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/vince/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/mysql2-0.4.6 for inspection.
Results logged to /home/vince/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/mysql2-0.4.6/gem_make.out

An error occurred while installing mysql2 (0.4.6), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.6' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  mysql2

红宝石版本是2.7.6,Rails 5.0.7.2,Environment Ubuntu 20.04

有没有人知道问题的起因和如何解决?我尝试过不同的堆栈溢出答案,但它们都没有帮助。

如果你需要更多的细节,请告诉我。

谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-11-17 11:51:48

您需要首先通过brew安装mysql

代码语言:javascript
复制
brew install mysql

然后尝试安装宝石。

代码语言:javascript
复制
gem install mysql2

成功后,请再次运行bundle install。

票数 0
EN

Stack Overflow用户

发布于 2022-11-18 08:58:22

我不知道这是否是完美的答案,然而,它解决了我的问题。

更改了gem文件中的mysql2版本,如下所示

代码语言:javascript
复制
gem 'mysql2', '~>0.5.4'

然后运行bundle install解决了我的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74265545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档