【发布时间】:2014-03-03 21:18:43
【问题描述】:
我正在尝试学习 Rails,但无法使用 MySQL 创建项目。 我使用 MAMP 在 OS X 10.9 上使用 PHP 进行开发,所以我试图配置我的 Rails 以使用它运行,但我不能。如果有人有一些教程或线索这里发生了什么,我将非常感激。
如果我必须在没有 MAMP 的情况下使用 apache 和 mysql 来解决这个问题,但只要告诉我是否真的有必要!
williamcalderipe@~/Projects/rails$ rails new mysql_app_test -d mysql
[...]
Fetching gem metadata from https://rubygems.org/...........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.8.4)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Using activesupport (4.0.2)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.2)
Using mime-types (1.25.1)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.2)
Using activemodel (4.0.2)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.2)
Using activerecord (4.0.2)
Using bundler (1.5.3)
Using coffee-script-source (1.7.0)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.2)
Using coffee-rails (4.0.1)
Using hike (1.2.3)
Using jbuilder (1.5.3)
Using jquery-rails (3.1.0)
Using json (1.8.1)
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/williamcalderipe/.rvm/rubies/ruby-2.0.0-p353/bin/ruby 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/williamcalderipe/.rvm/rubies/ruby-2.0.0-p353/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}/
--with-mysql-config
--without-mysql-config
extconf failed, exit code 1
Gem files will remain installed in /Users/williamcalderipe/.rvm/gems/ruby-2.0.0-p353/gems/mysql2-0.3.15 for inspection.
Results logged to /Users/williamcalderipe/.rvm/gems/ruby-2.0.0-p353/extensions/x86_64-darwin-12/2.0.0-static/mysql2-0.3.15/gem_make.out
An error occurred while installing mysql2 (0.3.15), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.15'` succeeds before bundling.
这是我的 config/database.yml
development:
adapter: mysql2
encoding: utf8
database: mysql_app_test_development
pool: 5
username: root
password: root
host: localhost
socket: /Applications/MAMP/tmp/mysql/mysql.sock
当我运行rails s
Could not find gem 'mysql2 (>= 0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
好的..所以缺少mysql2 我做了gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/williamcalderipe/.rvm/rubies/ruby-2.0.0-p353/bin/ruby 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:
[SAME CONFIGURATIONS AS THE FIRST CODE POSTED]
我的 XCode 版本是 5.0.2 (5A3005),所以当我执行 xcode-select --instal 并尝试安装命令行工具时,会发生这种情况:
【问题讨论】:
-
你的机器上安装了mysql服务器吗?
-
是的,我正在为 MySQL 和 Apache 服务器使用 MAMP!
标签: mysql ruby-on-rails ruby