Cannot install pg gem in Mavericks with Postgres.app - ruby-on-rails

I am trying to install the pg gem for use with Postgres.app on my local machine. I am running Mavericks.
Postgres.app is installed and running fine, but I cannot get the gem to work. I've done the following:
Used the command 'env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config' from the Postgres.app documentation
Updated Homebrew and installed the Apple GCC 4.2
Installed the Xcode developer tools
Updated my $PATH to reference both the Postgres.app bin and lib directories
All with no success. Here is the specific error message I receive:
Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config'
This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/Brian/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/MacOS/bin/pg_config
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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/Brian/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
--with-pg
--without-pg
--with-pg-config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/
I'd appreciate any help you can offer. Thanks!

You probably have the wrong path for --with-pg-config, check if it's actually there.
You can find the correct path to pg_config with:
find /Applications -name pg_config
In the latest Postgres.app Version the path is:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config

In my case (running Postgres.app v9.3.4.2) it only seemed to work when prepending the environment architecture flags:
env ARCHFLAGS="-arch x86_64" gem install pg -- \
--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config

Being on a brand new mac, here's what I had to do:
Install Xcode tools from the app store
Open Xcode tools and accept the license
Now run (hopefully a future-proofed command):
version=$(ls /Applications/Postgres.app/Contents/Versions/ | tail -1)
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/$version/bin/pg_config .
If you have trouble, you can troubleshoot a bit by checking out the actual error in the mkmf.log which you can find by running (if using rvm):
cd ~/.rvm ; find . -name mkmf.log | grep pg

I was able to install pg with this command
gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
I found my path by running
sudo find / -name "pg_config"
and I Successfully installed pg-0.17.1

adding the postgress bin dir to the path also does the trick. just add the bin to the pat like this. with recent installs the latest symbolic link makes sure that this path should be 'stable' for future version upgrades.
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin

To resolve this issue I installed postgres using homebrew using the following in the terminal window:
brew install postgres
Homebrew can be found here
http://brew.sh

This worked for me:
gem install pg -- --with-pg-config=`which pg_config`

For future reference, since a lot of us are posting new paths for the new version numbers:
Currently I'm seeing a symlink called latest in /Applications/Postgres.app/Contents/Versions/.
You should be able to just do:
$ gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
And forget about the version number. This might not apply to every (older) version, but I myself was looking for a snippet I could save and reuse.

Related

Getting PostgreSQL set up on Ubuntu bash running on Windows

I recently installed and set-up rails on an Ubuntu bash running on Windows as a Linux subsystem. I was able to get rails up and going without a problem and create a new rails application on my Windows C:/ drive. I tried downloading PSQL directly from the postgresql.org/downloads/windows website but had some issues so I canceled, then followed the Installing PostgresQL section of this tutorial. The only issue is that the previous download which was canceled was set to listen to the default Port 5432, and it appears to have kept the port occupied because the second installation said it had to use Port 5433.
EDIT: It appears that the original PSQL had been successfully installed as it appeared in my program list, I was able to uninstall it but did get an error warning that the data folder was not removed. After uninstalling and having only one installed copy of PSQL, I still get the same error when running the below sudo service postgresql start.
EDIT EDIT: I uninstalled both versions of PSQL completely and re-installed the version in the linked tutorial and it got rid of the second error I was having. However, my 'pg' gem is still not bundle installing.
Once that was complete, I tried switching over my existing rails application to postgresql. I updated the database.yml file and added the 'pg' gem to my Gemfile. I cannot, however, bundle install. When I try, I get this error:
Fetching pg 1.0.0
Installing pg 1.0.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/<user_profile>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/pg-1.0.0/ext
/home/<user_profile>/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20180717-4727-vex5p2.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a
client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a
client-side application.
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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/<user_profile>/.rbenv/versions/2.5.1/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/<user_profile>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0-static/pg-1.0.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/<user_profile>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/pg-1.0.0 for
inspection.
Results logged to
/home/<user_profile>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0-static/pg-1.0.0/gem_make.out
An error occurred while installing pg (1.0.0), and Bundler cannot continue.
Make sure that `gem install pg -v '1.0.0' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
pg
EDIT: Below is solved, refer to second edit above.
Similarly, when I try to start postgresql from the command line using sudo service postgresql start, I get the following:
$ sudo service postgresql start
* Starting PostgreSQL 9.5 database server * The PostgreSQL server failed to start. Please check the log output:
2018-07-17 14:59:26 DST [4858-1] LOG: could not bind IPv4 socket: Permission denied
2018-07-17 14:59:26 DST [4858-2] HINT: Is another postmaster already running on port 5433? If not, wait a few seconds and retry.
2018-07-17 14:59:26 DST [4858-3] WARNING: could not create listen socket for "localhost"
2018-07-17 14:59:26 DST [4858-4] FATAL: could not create any TCP/IP sockets
Does anybody know what is going wrong with the installation of PostgresQL in my environment and how I can get it successfully running on my Ubuntu shell?
Found the solution to these problems.
Issue #1 - 'pg' gem not installing
Execute the following in bash:
sudo apt-get install libpq-dev
gem install pg
bundle install
Issue #2 - postgresql cannot start without crashing
Uninstall all versions on PSQL on computer and reinstall one. The failed installation and the second version were sharing their data folder and caused errors with the installation I was using.

PostgreSQL gem for rails won't install, even when both home brew and app are installed

I have tried following this answer to get the gem to work, but it wont. I have my projects set up such that individuals projects have there own gems instead of all themes gems living in global space, and then I use binstubs to allow me to do things like bin/rails.
So all gems are installed to .bundle/gems/ for each project. the one that always gives me the toughest problems is posgresql. Lets go through the steps.
So I run:
bundle
It explodes stating:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
Gem files will remain installed in /Users/Adam/Documents/Rails-Projects/AisisPlatform/.bundle/gems/gems/pg-0.18.1 for inspection.
Results logged to /Users/Adam/Documents/Rails-Projects/AisisPlatform/.bundle/gems/gems/pg-0.18.1/ext/gem_make.out
An error occurred while installing pg (0.18.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.1'` succeeds before bundling.
So then, because I have the home brew version installed at 9.4.0 and the posgresql.app installed I then did:
bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Followed by, because I use 18.1
gem install pg -v '0.18.1'
And I got:
Building native extensions. This could take a while...
Successfully installed pg-0.18.1
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.18.1
Done installing documentation for pg after 2 seconds
1 gem installed
From there I tried bundle Well we are back to square one because even though the gem installed - I get the EXACT same error.
Is this because I am installing the pg gem globally and not locally? How can I fix this? This one project, every time I have to do a rm -rf .bundle/gems Causes this exact issue over and over again.
I should point out I get the same error even if I use the home brew psql pg_config Do all the steps above, just with home brew version, same results.
At the end of the day it was:
ARCHFLAGS="-arch x86_64" bundle install
that worked for me.
reason being:
by default it tries to compile a universal binary, which apparently
fails... so that environment variable makes it only compile the x86
version which is all you need
you can add this line to your ~/.profile or similar: export
ARCHFLAGS="-arch x86_64"
For further reading see: This README for OSX
Make sure Postgres is installed on your computer first
for Ubuntu systems: sudo apt-get install libpq-dev
on RHEL systems: yum install postgresql-devel
for Mac: brew install postgresql
Then run bundle install
I used these commnads of this link
rails 4.2.0: can't install pg gem on ubuntu 14.04
You need install the postgreSQL dev package with header of PostgreSQL
sudo apt-get install libpq-dev
You may also try
sudo apt-get install postgresql-client
sudo apt-get install postgresql postgresql-contrib
Try env ARCHFLAGS="-arch x86_64" gem install pg
Try install postgresql-devel package:
yum -y install postgresql-devel
Notice that the above command wont't ask for permission because of the -y
Confirming Antarr Byrd's answer,
sudo env ARCHFLAGS='-arch x86_64' gem install pg
worked for me.

gem install rails ERROR: While executing gem ... (Errno::EACCES)

I somehow messed my $PATH up. (changed it) and my ruby and rails gems weren't working. What I did in efforts to fix this was to reinstall RVM. Now my ruby works fine in the Terminal.
On running gem install railsI get greeted with this:
Permission denied - /Users/emKaro/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.13/test/test_atomic.rb
When I try to install rails through sudo gem install rails, I get this error:
ERROR: While executing gem ... (Errno::EACCES)
I have XCode installed with Command-Line tools installed as well. Even went ahead to install GCC but get the very same error when I try to install rails.
This is the full error message
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Users/emKaro/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.13/test/test_atomic.rb
emmanuels-imac:~ siaW$ sudo gem install rails
Password:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
*** 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/emKaro/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
--with-atomic_reference-dir
--without-atomic_reference-dir
--with-atomic_reference-include
--without-atomic_reference-include=${atomic_reference-dir}/include
--with-atomic_reference-lib
--without-atomic_reference-lib=${atomic_reference-dir}/
/Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
from /Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:817:in `try_run'
from extconf.rb:24:in `<main>'
Gem files will remain installed in /Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.13 for inspection.
Results logged to /Users/emKaro/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.13/ext/gem_make.out
I am the admin of my computer and running Mac OS 10.8.3. I'd appreciate some help with the rails install.
EDIT:
Thanks #Christoph
The only code that helped was to actually remove the RVM folder with
sudo rm -rf ~/.rvm/
I tried only to uninstal and it didn't work. So removing the folder and then reinstalling RVM does the job.
Like Dave pointed out up there, there should be no need to sudo any Gem installation. You could try to reset the permissions on your RVM directory:
sudo chown -R emKaro: ~/.rvm/
and try your Gem instllation again. If that doesn't work out, you should consider removing your RVM installation and start over:
sudo rm -rf ~/.rvm/ # remove your RVM directory
There should really be no need for using sudo in any of this.
I'm running 10.8.5 OSX and was trying to install Rails with Ruby 1.9.3-p448 - so I don't know if it's exactly the same problem, but by looking in the mkmf.rb code where it failed, I found that the problem was that the basic CC command wasn't running. For some reason, it needed to search for the folders in /usr/local, and for some reason, /usr/local was set to 740 permissions on my install (which I had gotten from someone else so not sure what he had done prior to my getting the machine.)
So after I did chmod +x /usr/local, everything worked ok.
I had this problem in Ubuntu, but it was because I didn't installed the rvm with "Run command as a login shell", after the installation of rvm they told about this, and the link to look for the information to enable in ubuntu.
Here's the link:
https://rvm.io/integration/gnome-terminal
For RVM to work properly, you have to check the 'Run command as login shell' checkbox on the Title and Command tab of gnome-terminal's Edit ▸ Profile Preferences menu dialog, in case the menu is missing right click the terminal app and navigate Profiles ▸ Profile Preferences.

Problem in SQLite3 installation

The following error comes up:
C:\gem>gem install sqlite3-ruby --local
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
C:/Ruby/bin/ruby.exe extconf.rb
checking for #include <sqlite3.h>
... no
sqlite3.h is missing. Install SQLite3 from http://www.sqlite.org/ first.
*** 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
--srcdir=.
--curdir
--ruby=C:/Ruby/bin/ruby
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1
.3.0 for inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.3.0/ext/sqlite3/
gem_make.out
I have copied all the necessary files required in the Ruby/Bin folder, still it keeps reporting this error that sqlite3.h is missing.
Please do tell where do I have to place sqlite3.h, when I am installing the gem locally as you can see and I am currently using 1.3.0 version of SQLite3 for its installation.
I have tried with the solutions that were posted for similar problems. And I am using Windows XP.
Thanks in advance.
I had this problem. This is the solution I found. It's not very pretty, but it worked for me. In my case, I was using cygwin. There's probably a similar way to do it without using cygwin, but I don't know how.
1) Download the source of SQLite. I went for SQLite 3.6.23, somewhat arbitrarily, via this URL:
http://www.sqlite.org/src/info/4ae453ea7b
If that doesn't work, then go to the release timeline at http://www.sqlite.org/src/timeline?n=200&t=release&y=ci , choose a release, and download the ZIP file of it.
2) Unpack the ZIP archive somewhere. Go to that directory in cygwin. Execute these commands:
./configure
make
make sqlite3.dll
make install
3) Copy the sqlite3.exe and sqlite3.dll from the directory where make created them into somewhere on your path.
4) Once that's done, gem install sqlite3-ruby finally worked.
I was following this guide: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/240902
I know this has been closed for a while but I was having the same issue and this
helped. Install apt-cyg. First install subversion and wget through the standard
cygwin setup program. Then run the following commands:
wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg
install apt-cyg /bin
Now using apt-cyg install the sqlite3 development:
apt-cyg install libsqlite3-devel
and finally
$ gem install sqlite3-ruby
Building native extensions. This could take a while...
Fetching: sqlite3-ruby-1.3.3.gem (100%)
#######################################################
Hello! The sqlite3-ruby gem has changed it's name to just sqlite3. Rather than
installing `sqlite3-ruby`, you should install `sqlite3`. Please update your
dependencies accordingly.
Thanks from the Ruby sqlite3 team!
<3 <3 <3 <3
#######################################################
Successfully installed sqlite3-1.3.6
Successfully installed sqlite3-ruby-1.3.3
2 gems installed
Installing ri documentation for sqlite3-1.3.6...
Installing ri documentation for sqlite3-ruby-1.3.3...
Installing RDoc documentation for sqlite3-1.3.6...
Installing RDoc documentation for sqlite3-ruby-1.3.3...
I got it working by following these suggestions: http://www.skorks.com/2009/08/installing-and-using-sqlite-with-ruby-on-windows/
Basically you can download from sqlite.org, the DLL and shell file and make sure you copy the DLL in each of the ruby versions you have installed, in their /bin directory. You can place the shell file somewhere in your system path, I have a folder c:\bin. Then you can install pik gem install sqlite3
replace with sqlite3 (1.3.10-x64-mingw32) in Gemfile.lock worked for me.

How to install mysql gem on Mac os 10.6?

i just installed MAMP on this iMac and the rubygems but when i run:
sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
gives me
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
ERROR: could not find gem — locally or in a repository
ERROR: could not find gem –with-mysql-config=/usr/local/mysql/bin/mysql_config locally or in a repository
how can i install this gem ?
I found this and worked out perfectly:
you can go to http://www.tmtm.org/en/ruby/mysql/ to download the tar
file, and run the command below
# ruby ./install.rb
to install the mysql.rb
Use the following it worked with me
brew install mysql
Do you have the Xcode developer tools installed on Mac OS X? If not, I'd start there.
You can download them here: http://developer.apple.com/technologies/xcode.html
Once you've installed that, try again.
i'm still getting this
$ sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... no
checking for mysql/mysql.h... 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
--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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
--with-mysql-config
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
You need the mysql development libs to compile it. If you were on linux you could use "yum install mysql-devel". Not sure about how to get them installed on a mac, but try downloading the connector libraries from here:
MySql Connector Downloads
You may have to pass in a --with-mysql-libs option to point to the directory when the C libraries are unpacked to. Hope this points you in the right direction.
Or you can just put the libraries in the default directory:
/usr/lib64/mysql
Download mysql-dev from mysql.com

Resources