简体   繁体   English

无法在MAMP上安装mysql2 Gem

[英]Can't install mysql2 Gem on MAMP

After running bundle install, I got this error. 运行软件包安装后,出现此错误。 I've tried editing the /etc/paths file and it still hasn't worked. 我试过编辑/ etc / paths文件,但仍然没有用。

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. Gem :: Ext :: BuildError:错误:无法构建gem原生扩展。

/Users/adam/.rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20150224-4249-ltvvu1.rb extconf.rb 
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /Applications/MAMP/Library/bin/mysql_config
-----
checking for mysql.h... no
checking for mysql/mysql.h... yes
checking for errmsg.h... no
-----
errmsg.h is missing.  please check your installation of mysql and try again.
-----
*** 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=/Users/adam/.rvm/rubies/ruby-2.1.5/bin/ruby
    --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

extconf failed, exit code 1

Gemfile 的Gemfile

ruby-2.1.5
gem 'rails', '4.1.7'
gem 'mysql2'

/etc/paths 的/ etc /路径

/Applications/MAMP/Library/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

Is this related to my MySql installation? 这与MySql安装有关吗?

尝试:

gem install mysql2 -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

I've fixed this by simply running gem install using the mysql config an existing config. 我通过使用mysql配置现有配置运行gem install来解决这个问题。

gem install mysql2 -v {mysql2_gem_version} --  --with-mysql-config=/usr/local/Cellar/mysql/{mysql_gem_version}/bin/mysql_config



gem install mysql2 -v '0.3.17' -- --with-mysql-config=/usr/local/Cellar/mysql/5.6.21/bin/mysql_config

Try this: 尝试这个:

First add the below dependencies by using below commands: 首先使用以下命令添加以下依赖项:

sudo apt-get install mysql-server-5.5

sudo apt-get install mysql-client libmysqlclient-dev

sudo apt-get install libmysqld-dev libmysqlclient-dev mysql-client

Finally Add gem 'mysql2', '~> 0.3.16' in Gemfile and bundle install 最后在Gemfile中添加'mysql2', '~> 0.3.16'并捆绑安装

Off topic: 无关:

I experienced this problem when I deployed my app to production (Linux Server) 我将应用程序部署到生产环境时遇到此问题(Linux Server)

I had to install this to fix the missing gem 我必须安装它来修复丢失的宝石

yum install mysql-devel 百胜安装mysql-devel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM