当前位置: 首页 > 面试题库 >

错误:无法构建gem本机扩展(在Rails 3.2.3上为mysql2)

壤驷志学
2023-03-14
问题内容

我正在尝试使用Rails 3.2.3安装mysql2 gem,但失败了:

★  bundle install
Fetching gem metadata from https://rubygems.org/.........
Using rake (0.9.2.2) 
Using i18n (0.6.0) 
Using multi_json (1.2.0) 
Using activesupport (3.2.3) 
Using builder (3.0.0) 
Using activemodel (3.2.3) 
Using erubis (2.7.0) 
Using journey (1.0.3) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.1) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.2) 
Using actionpack (3.2.3) 
Using mime-types (1.18) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.4.4) 
Using actionmailer (3.2.3) 
Using arel (3.0.2) 
Using tzinfo (0.3.32) 
Using activerecord (3.2.3) 
Using activeresource (3.2.3) 
Using bundler (1.1.3) 
Using coffee-script-source (1.2.0) 
Using execjs (1.3.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.2) 
Using json (1.6.6) 
Using rdoc (3.12) 
Using thor (0.14.6) 
Using railties (3.2.3) 
Using coffee-rails (3.2.2) 
Using jquery-rails (2.0.2) 
Installing mysql2 (0.3.11) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/rarneson/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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
    --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=/Users/rarneson/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
    --with-mysql-config
    --without-mysql-config
    --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-mysqlclientlib
    --without-mysqlclientlib
    --with-mlib
    --without-mlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-zlib
    --without-zlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-socketlib
    --without-socketlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-nsllib
    --without-nsllib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mygcclib
    --without-mygcclib
    --with-mysqlclientlib
    --without-mysqlclientlib


Gem files will remain installed in /Users/rarneson/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/rarneson/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
An error occured while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.

我正在运行捆绑安装,这在我的Gemfile中:

gem 'mysql2', '~> 0.3.11'

我目前已经通过MAMP运行MySQL。我不确定这是否是个坏主意,我应该运行香草MySQl,但似乎我当前的问题只是安装gem。我在stackoverflow上已经看到了很多这样的问题,但是似乎都有些不同或解决方案非常复杂。有什么我想念的吗?简单吗?有点蠢吗?如果需要,我可以从out文件中提供其他信息。我读过一些人使用SQLite进行开发和测试,然后在产品中测试MySQL,但这听起来像一个非常可怕的想法。


问题答案:

我最终只是安装了一个全新的MySQL副本,而没有使用MAMP,就成功了。还必须确保安装64位版本,而不是32位版本。



 类似资料:
  • 我正在尝试基于ruby: 3.0构建Docker映像。在Dockerfile中,运行“RUN bundle install”时,开始安装依赖项,直到显示错误: Gem::Ext::BuildError:错误:未能生成Gem本机扩展#10 34.20 34.20当前目录:/usr/local/bundle/gems/tiny_tds-2.1.5/ext/tiny-tds#10 34.2/usr/lo

  • 问题内容: 我正在尝试将MySQL安装到最新版本,这是因为某些安装错误。我运行命令,并且收到以下信息: 构建本机扩展。这可能需要一段时间…错误:安装mysql时出错:错误:无法生成gem本机扩展。 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb extconf.rb:4:警告:PATH模式

  • 问题内容: 尝试为Rails 安装gem 时遇到一些问题。当我尝试通过运行安装它时,或者出现以下错误: 安装mysql2时出错:错误:无法构建gem本机扩展。 如何解决此问题并成功安装? 问题答案: 在Ubuntu / Debian和其他使用aptitude的发行版上: 软件包已被淘汰,并由代替。这是我找到解决方案的地方。 如果上述命令由于找不到而无法使用,则以下内容就足够了: 在Red Hat

  • 问题内容: 操作系统:Mac OS X 10.10.3 XCode:最新安装了命令行工具(6.3版)Rails:4.2.1版Ruby:2.2.1版 当我收到一条错误消息时,我试图为正在处理的项目生成路由(定期执行此操作),并建议我捆绑安装并捆绑执行。我这样做了,这一次,编译JSON Gem(版本1.7.7)的过程中断了。 对StackOverflow进行了一些研究,建议是更新Xcode的命令行工具

  • 问题内容: 我正在使用Fedora 14,并且已安装并正在运行MySQL和MySQL服务器5.1.42。现在,我尝试以root用户身份执行此操作: 但是我得到这个错误: 怎么了 在已安装的Ruby 1.8.7中。以及最新的rubygems 1.3.7。 问题答案: 对于那些可能对接受的答案感到困惑的人,就像我一样,您还需要安装ruby标头[ ruby-devel ]。 保存我的皮革的文章在这里。

  • 我正在尝试将rails应用程序部署到我的ubuntu linux服务器上。我正在使用capistrano和bundler,当安装gems时,它会失败,并出现以下错误: 我运行的是ruby enterprise edition 1.8.7,如果不升级其他网站,我就无法升级ruby,所以现在这不是一个选项。我尝试安装ruby dev,但没有任何帮助(我不确定这是不是正确的事情)。