Skip navigation links

MySQL Forums :: Ruby :: Error when install mysql gem for ruby


Advanced Search

Re: Error when install mysql gem for ruby
Posted by: mike montagne ()
Date: March 21, 2010 12:09AM

Please note that for the benefit of the many who are suffering related mysql gem installation problems, these instructions have been revised to account for possible inclusion of the ri and RDoc resources which were missing here (and to which these instructions relate).

Please find even more comprehensive instruction therefore at:

http://forums.mysql.com/read.php?116,359591,359591#msg-359591

Regards,

mike montagne


Nate Lieby Wrote:
-------------------------------------------------------
> Hi,
>
> This is a bit of a duplicate, but I've yet to see
> a solution for linux in regards to this issue.
>
> All workarounds point to using a dll, which will
> only work in windows. Here is the output of
> attempting to install the ruby gem:
>
> sudo gem install mysql
> Building native extensions. This could take a
> while...
>
> Successfully installed mysql-2.8.1
> 1 gem installed
>
> Installing ri documentation for mysql-2.8.1...
>
> No definition for next_result
> No definition for field_name
> No definition for field_table...ETC.
>
> Installing RDoc documentation for mysql-2.8.1...
>
> No definition for next_result
> No definition for field_name
> No definition for field_table...ETC.
>
> From other threads, I've heard that using an older
> version of msql will fix things, but that is not
> ideal. any other ideas?
>
> thanks,
>
> -nate

Hi Nate,

This one was a bear for me (new to Ruby). After much frustration following various instructions (many of which were wrong or apply only to given installations), and after deciphering what was going awry for my particular system (no instruction matched, not even the comment in database.yml), I was able to get the mysql gem to install on:

OSX Leopard 10.6.2
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
Rails 2.3.5
mysql (2.8.1) [gem version]
MySQL Server 5.1.44

The gem is actually compiled by the install gem process. Documentation is poorly written. As far as I could determine, you probably have to do two things: 1) you have to find the directory in which your gem resources are stored, so that you can cd to that directory for your build/install process; and 2) you have to find the location of mysql_config on your system, so that you can pass the installation process the right instruction for the build. For all I know, it might not be necessary to cd to the gem folder for your build, but as I found others trying to follow this pattern, I took the precaution of doing so. No need to inadvertently introduce unnecessary consequences.

If you have a bad install, first uninstall your gem from terminal:
sudo gem uninstall mysql

Check your results with:
gem list
There should be no mysql gem listed.

To install:

1. RESOLVE PATH TO GEM FOLDER

On my system, the path to the folder containing the mysql gem ([GemFolder]) is:
/Library/Ruby/Gems/1.8/gems/mysql-2.8.1

This path can vary greatly as a consequence of distribution. You might find your gem folder path by searching for gems, mysql-, etc.:
sudo find / -name "mysql-" -print

2. RESOLVE PATH TO mysql_config

On my system, the path to mysql_config ([mysql_configPath]) is:
/usr/local/mysql/bin/mysql_config

To locate mysql_config on my system, I logged in with root privileges and did:
find / -name "mysql_config" -print
or
sudo find / -name "mysql_config" -print

3. ABOUT ri AND RDoc

I haven't nailed down exactly what ri and RDoc are, except that they appear to provide design-time documentation. Support for intended functions is evidently missing (? not sure) from the mysql compile resources. You can instruct the compiler/installer not to look for the supporting resources with the following --no-rdoc and --no-ri switches.

4. INSTALLING THE GEM WITH THESE VITAL PIECES

4.A. IN TERMINAL, FIRST cd TO YOUR [GemFolder];

cd [GemFolder]
...on my system, this translated to:
cd /Library/Ruby/Gems/1.8/gems/mysql-2.8.1

4.B. ISSUE THE INSTALL COMMAND, CONSTRUCTED WITH THE FOLLOWING PARAMETERS

sudo gem install mysql --no-rdoc --no-ri -- --with-mysql-config=[mysql_configPath]
...on my system, this translated to:
sudo gem install mysql --no-rdoc --no-ri -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Hope this post does not truncate this statement. There is one space between each of the terms, all on one line. Of course, the --no-rdoc and --no-ri switches relieve the compiler/installer of what they can't do. rdoc and ri documentation I found indicated that the .html documentation is usually preferable. You'll probably find that in your gem folder.

If all this works, there should be absolutely no errors in your install process. I was able to successfully "install" by other procedures, but found my development environment dysfunctional in critical respects. So, I would say to settle for nothing less than an error and warning free build. The way things are going, I imagine that will save a lot of headache down the road.

Hope this helps,

mike montagne



Edited 2 time(s). Last edit at 03/21/2010 12:25PM by mike montagne.

Options: ReplyQuote


Subject Written By Posted
Error when install mysql gem for ruby Nate Lieby 02/12/2010 01:08PM
Re: Error when install mysql gem for ruby mike montagne 03/21/2010 12:09AM
Re: Error when install mysql gem for ruby mike montagne 03/21/2010 12:06PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.