无法在 MAMP 上安装 mysql2 Gem
Can't install mysql2 Gem on MAMP
运行 捆绑包安装后,出现此错误。我试过编辑 /etc/paths 文件,但还是没用。
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
Gem文件
ruby-2.1.5
gem 'rails', '4.1.7'
gem 'mysql2'
/etc/paths
/Applications/MAMP/Library/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
这与我的 MySql 安装有关吗?
试试这个:
首先使用以下命令添加以下依赖项:
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
最后在 Gemfile 中添加 gem 'mysql2', '~> 0.3.16'
并捆绑安装
题外话:
我在将我的应用程序部署到生产环境(Linux 服务器)时遇到了这个问题
我必须安装它来修复丢失的 gem
yum 安装mysql-devel
我已经解决了这个问题,只需 运行 gem 使用 mysql 配置和现有配置进行安装。
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
尝试:
gem install mysql2 -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
运行 捆绑包安装后,出现此错误。我试过编辑 /etc/paths 文件,但还是没用。
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
Gem文件
ruby-2.1.5
gem 'rails', '4.1.7'
gem 'mysql2'
/etc/paths
/Applications/MAMP/Library/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
这与我的 MySql 安装有关吗?
试试这个:
首先使用以下命令添加以下依赖项:
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
最后在 Gemfile 中添加 gem 'mysql2', '~> 0.3.16'
并捆绑安装
题外话:
我在将我的应用程序部署到生产环境(Linux 服务器)时遇到了这个问题
我必须安装它来修复丢失的 gem
yum 安装mysql-devel
我已经解决了这个问题,只需 运行 gem 使用 mysql 配置和现有配置进行安装。
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
尝试:
gem install mysql2 -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config