Topic: Rails upgrade broke MySQL connection

After months of delay, I finally update to Rails 2.2.2. Until now I was running 1.2.6, which I built on my PowerMac Dual G5, OS 10.4.11 using the method from Hivelogic's site that uses Xcode. It has been solid until now.

Now that I've upgraded MySQL no longer works. I've install the MySQL gem 2.7. I get the following message:

$ gem install mysql
Attempting local installation of 'mysql'
Local gem file not found: mysql*.gem
Attempting remote installation of 'mysql'
Select which gem to install for your platform (powerpc-darwin8.7.0)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. mysql 2.5.1 (ruby)
6. Cancel installation
> 3
Building native extensions.  This could take a while...
ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no

make
make: Nothing to be done for `all'.

make install
make: Nothing to be done for `install'.
Successfully installed mysql-2.7

On another note, when I attempted updating Ruby, I receive the follow error message:

$ gem update ruby --include-dependencies
Upgrading installed gems...
Attempting remote upgrade of ruby
Attempting remote installation of 'ruby'
ERROR:  While executing gem ... (Gem::GemNotFoundException)
    Could not find ruby (> 0) in the repository



I've tried connecting to my db using YourSQL and it doesn't work either. I would appreciate any help from the Mac users.

Thanks,
Aaron

Last edited by RustyHack (2008-12-30 16:15:40)

"And he has commited to us the message of reconciliation, ..." 2 Cor. 5:19,20

Re: Rails upgrade broke MySQL connection

Do you have MySQL installed and not just the gem? Also, you don't update Ruby like that because Ruby is not a Gem, but a language. Not sure what version of ruby you are running (you can find out by doing ruby -v), but I'd suggest not moving to 1.8.7 and not going 1.9.1 yet. Stick is with 1.8.6, at the latest patch level.

Re: Rails upgrade broke MySQL connection

Robert,

Here is my setup. I get the following error message when getting my rails version. By the way, MySQL is installed and is only available to my app. I can't use YourSQL any more to access my db.

localhost:~ aaronhyde$ ruby -v
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.7.0]
localhost:~ aaronhyde$ rails -v
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor.rb:5: undefined method `gem' for main:Object (NoMethodError)
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support.rb:24
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
        from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record.rb:25
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:182:in `activate'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:181:in `activate'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:167:in `activate'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:166:in `activate'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:31:in `require_gem'
        from /usr/local/bin/rails:17


Does that error look familiar?

"And he has commited to us the message of reconciliation, ..." 2 Cor. 5:19,20

Re: Rails upgrade broke MySQL connection

I'd suggest updating your Ruby install and your RubyGems. For updating Ruby, you can go to the ruby-lang.org site and download a copy to install. For RubyGems you'll have to do the following:

sudo gem install rubygems-update
sudo update_rubygems

The error you are seeing should be because you have an old verison of RubyGems - not 1.3.1 which is the newest. You can do gem -v to see what version you have.

Re: Rails upgrade broke MySQL connection

Robert, I ran your suggestions, which updated my gems to 1.3.1. I'm running Ruby 1.8.4 and have gems 1.3.1 installed. I think I messed up my Rails install. When I check the version ($rails -v), I'm getting the following error:

$/user/local/bin/rails:17: undefined method 'require_gem' for main:Object (NoMethodError)

I believe I'm going to have to rebuild my Rails. Do you have experience with MacPorts or Fink for updating Rails? If so, what has been your experience?

"And he has commited to us the message of reconciliation, ..." 2 Cor. 5:19,20

Re: Rails upgrade broke MySQL connection

I personally don't like using macports or fink for my machine. I use apt-get and yum on linux, but I build my libraries on my local machine.

For rails, you just need to do: sudo gem install, since rails is a rubygem.

Re: Rails upgrade broke MySQL connection

Something went wrong somewhere. As you can see below, I have Gems 1.3.1, Rails 2.2.2 and Ruby 1.8.4. When I try to launch the server, it fails.


$ gem update rails --include-dependencies
Updating installed gems
Nothing to update
$ which ruby
/usr/local/bin/ruby
$ which rails
/usr/local/bin/rails
$ gem -v
1.3.1
$ rails -v
Rails 2.2.2
$ ruby -v
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.7.0]
$ script/server
./script/../config/boot.rb:25:Warning: Gem::SourceIndex#search support for String patterns is deprecated
./script/../config/boot.rb:28: undefined method `require_gem' for main:Object (NoMethodError)
        from script/server:2
$

I tried setting my gems with 1.2.6 and 1.3.1 but the same error. Should I be running Ruby 1.8.6?

"And he has commited to us the message of reconciliation, ..." 2 Cor. 5:19,20

Re: Rails upgrade broke MySQL connection

that error looks like its from your rails application. Have you updated your application for rails 2.2.2? Also, I suggest you update your ruby install to 1.8.6.

Re: Rails upgrade broke MySQL connection

I've installed Ruby 1.8.6 and got following error. I went back to 1.8.4 and get the same message now.

localhost:~/Desktop/testapp aaronhyde$ script/server
=> Booting lighttpd (use 'script/server webrick' to force WEBrick)
=> Rails 2.2.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server (see config/lighttpd.conf for options)
/usr/local/bin/rake:17: undefined method `require_gem' for main:Object (NoMethodError)


Here is what is in rake. If you have any ideas, please let me know.

1. #!/usr/bin/env ruby
2. #
3. # This file was generated by RubyGems.
4. #
5. # The application 'rake' is installed as part of a gem, and
6. # this file is here to facilitate running it.
7. #
8.
9. require 'rubygems'
10. version = "> 0"
11. if ARGV.size > 0 && ARGV[0][0]==95 && ARGV[0][-1]==95
12.  if Gem::Version.correct?(ARGV[0][1..-2])
13.    version = ARGV[0][1..-2]
14.    ARGV.shift
15.   end
16. end
17. require_gem 'rake', version
18. load 'rake' 


Things look like they are going downhill from here. First it was loosing my mysql connection, which still doesn't work, now this. sad

"And he has commited to us the message of reconciliation, ..." 2 Cor. 5:19,20

Re: Rails upgrade broke MySQL connection

One more thing I discover migrating to (Rails 2.2.2, Gems 1.3.1) was that I had to replace boot.rb in my old app with the boot.rb from a new test app in order to work. Still no MySQL contact. I don't know if anyone else had this experience or not.

"And he has commited to us the message of reconciliation, ..." 2 Cor. 5:19,20

Re: Rails upgrade broke MySQL connection

Like I said, you are gonna have to update your application to work with Rails 2.2.2, since your app was built for 1.2.6.

Can you go to the terminal and do mysql -uroot -p and get the mysql prompt for the root password? If you know the password for root, put it in and see if you can connect to mysql.

You're app has to be update, by yourself, to work with the new version of Rails.

Re: Rails upgrade broke MySQL connection

I've updated all of my code and removed anything that is no longer supported, deprecated, before updating my RoR setup. After a little googlin',  I found a fix for the rake error message:

$ gem install rake

1 down and 1 to go.


I don't get the mysql prompt either. I've tried "mysql" and "mysqladmin", with no positive results. It tells me that it is an unrecognized command. My bash_login looks like:

alias mysql="/usr/local/mysql/bin/mysql"
alias mysqladmin="/usr/local/mysql/bin/mysqladmin"
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
export PATH="/usr/local/mysql/bin:$PATH"

It doesn't appear that mysql is showing anywhere in my load paths. If I do the following, I can get mysql to respond.

$cd /usr/local/mysql/bin
$./mysqladmin

This is fine for testing but doesn't work with RoR. By the way, the Preference Pane for MySQL can start and stop the db server with no errors.

UPDATE
After more googlin', I discover another system file used by Terminal called .bash_profile. After a little playing around, I discovered that Terminal was using it instead of .bash_login, which is what I used when I originally configured my system. I still can't get MySQL to respond to a command yet.

Last edited by RustyHack (2009-01-06 17:54:27)

"And he has commited to us the message of reconciliation, ..." 2 Cor. 5:19,20

Re: Rails upgrade broke MySQL connection

I'm posting this for anyone else who may have run into this problem. I discovered that my MySQL upgrade change location and name of my MySQL socket. I found the following code, which fixed the db connection. Now I have to figure out how to restore my MySQL privileges.

  adapter: mysql
  database: db_name
  username: root
  password:
  host: localhost
  socket: <%=
        ['/usr/local/var/run/mysql/mysqld.sock', # darwinports
         '/usr/local/var/run/mysqld/mysqld.sock', # darwinports, again
         '/var/run/mysqld/mysqld.sock',           # ubuntu/debian
         '/tmp/mysql-vcw.sock'].select { |f| File.exist? f }.first %>


I hope that helps someone else.

"And he has commited to us the message of reconciliation, ..." 2 Cor. 5:19,20