From: Luis Lavena Date: 2008-01-23T23:14:57+09:00 Subject: Re: Ruby on Windows with mysql and net On 23 ene, 10:31, "Simon Jones" wrote: > Hello all, > > I'm a new Ruby user, so pardon me if this is a silly question, but I've done > some googling and not found any answers so far. Apologies in advance if this > post is a little long, but I thought it might help to list what I've done so > far. > No problem, I'm used to write long posts :-) > I've downloaded Ruby 1.8.6 One-Click Installer, and got Ruby up and running > on my Win XP box. Then I used RubyGems to obtain v 2.7.3 of the MySQL API. > > The idea is to connect to MySQL running on Ubuntu Server on another box on > my LAN - that part of the equation seems to work ok, in that I can connect > to MySQL from the Windows box using MySQL Administrator etc. The data to be > retrieved is login details (server, username, password) for several POP3 > mail boxes - I eventually want Ruby to get details for each box from the > database, connect to the mailbox, download mail and process it etc.. > > However, when I tried to query the database via Ruby I got a Segmentation > Fault. After much googling I found I needed libmySQL.dll in my path, and > tried various versions of the file (including the one that came with MySQL > Administrator, and the one in MySQL 5.1.22), before getting things to work > with the version from MySQL 5.0.45. > The pre-build gem of mysql 2.7.3 is build for 5.0.x version of MySQL, anything above that will generate a segfault due changes in the API/ exported symbols of libmySQL.dll > Great, Ruby can now retrieve a result set from the database containing login > details for the two POP3 boxes currently stored there. Also, by using the > demo code in the docs for net/pop and hard coding the login details for any > given mailbox, I can connect to the mail server. > > But, when I merge the code together, things go slightly wrong. Ruby > retrieves the details from the database and connects to the mail servers > correctly, but, when the program ends, I get: > > Error in my_thread_global_end(): 1 threads didn't exit > > >Exit code: 0 > That is correct, nothing wrong with your code. Is a known problem of MySQL 5.0.x, and still wasn't solved in latest version of it: http://bugs.mysql.com/bug.php?id=25621 The problem is the lack of a newer version of the installers (official ones) for 5.0.x and the issue I mention above about pre-build gem. > The code I'm using is below. It's messy and long winded, but it IS my first > attempt ever at writing Ruby code - I like what I see so far, and I WILL get > better at it :-) You code looks good. The issue also happens on other platforms, not just Windows ;-) > Any suggetions would be very much appreciated! Just ignore the error for the time being? :-) I'm doing that on a daily basis, so maybe you can too ;-) Regards, -- Luis Lavena