Topic: Upgrading My App to Rails 1.2.1

I have no idea how to upgrade my rails 1.1.6 app to 1.2.1.  Can someone give me some pointers on what actually needs to be done?  The only error I see in the log is: No such file or directory - /tmp/mysql.sock

All I did was create a new project in rails 1.21.  I then copied my app directory over, my assets and some other config files (environment.rd, routes.rb, etc).  When I try and run the site I get a 500 Error:
"We're sorry, but something went wrong.

We've been notified about this issue and we'll take a look at it shortly."

Re: Upgrading My App to Rails 1.2.1

You don't need to copy your files into a new rails project.  All you need to do is go to your existing project and type the following command into the command line:

rake rails:freeze:edge TAG=rel_1-2-3

that will install the latest stable Rails (version 1.2.3) into your application.  What it technically does is copies rails into your vendor/rails folder inside your project.  Then, when your project starts up it knows to look there first for Rails.  If vendor/rails is missing then it'll look elsewhere.

That's  all :-)

Re: Upgrading My App to Rails 1.2.1

I appreciate the reply.  I get this error when running that command:

bob@bobbyhotep:~/rails/test$ rake rails:freeze:edge TAG=rel_1-2-1
(in /home/bob/rails/test)
Cannot find gem for Rails =1.2.1:
    Install the missing gem with 'gem install -v=1.2.1 rails', or
    change environment.rb to define RAILS_GEM_VERSION with your desired version.
 
rake aborted!
exit
/home/bob/rails/test/Rakefile:4:in `require'
(See full trace by running task with --trace)

I updated my environment.rb to reflect the new version.  If I create a new project and run the default page it tells me i'm running v1.2.1 of rails.  I have no idea why it says that more gems need to be installed.

Last edited by BIGtrouble77 (2007-03-24 03:34:48)

Re: Upgrading My App to Rails 1.2.1

when Rails is only installed as a gem it's called "floating off the gems".  It's not very reliable and any time one of your gems gets updated it can break your application.  I'd recommend commenting out the RAILS_GEM_VERSION in your environment.rb file for now and sticking with rails in your vendor/rails directory.  It's the best way to be *sure* what version you're going to be running.

Re: Upgrading My App to Rails 1.2.1

So I found where rails was installed and copied it to the vendor directory (and changed the permissions).  I then had to install svn for your command to run.  The rake seemed to work.  But when I try to access the main controller I get an error:

Application error

Change this error message for exceptions thrown outside of an action (like in Dispatcher setups or broken Ruby code) in public/500.html


The rails default start page works fine.

Re: Upgrading My App to Rails 1.2.1

The rails default start page is just an html file - you should delete it now that your app is up and running.

Now that you've got that error you get to join the wonderful world of debugging :-)

The first step is always to look at the bottom of your log file (usually log/development.log) for the error message that Rails has recorded.  Anytime it gives you that 'Application Error' page it actually records a lot of detail about the error in the log.

So check out the log and it'll give you some clues as to what's missing or what Rails can't seem to do.  As soon as you get stuck feel free to post the snippet from your log file here and ask for help.

Good luck!

Re: Upgrading My App to Rails 1.2.1

I have been going through the log, but there's nothing in it that explicitely states there is an error.  The only two things I'm seeing here is the mysql notice at the very beginning and a lot of notices about dependencies.  Here's the log:

No such file or directory - /tmp/mysql.sock
./script/../config/../vendor/rails/activerecord/lib/active_record/vendor/mysql.rb:107:in `initialize'
./script/../config/../vendor/rails/activerecord/lib/active_record/vendor/mysql.rb:107:in `new'
./script/../config/../vendor/rails/activerecord/lib/active_record/vendor/mysql.rb:107:in `real_connect'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:389:in `connect'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:152:in `initialize'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:82:in `new'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:82:in `mysql_connection'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:262:in `send'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:262:in `connection_without_query_cache='
./script/../config/../vendor/rails/activerecord/lib/active_record/query_cache.rb:54:in `connection='
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:230:in `retrieve_connection'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1137:in `add_limit!'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1099:in `construct_finder_sql'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:994:in `find_every'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:415:in `find'
./script/../config/../app/helpers/application_helper.rb:3
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:204:in `load_without_new_constant_marking'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:204:in `load_file'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:343:in `new_constants_in'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:203:in `load_file'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:95:in `require_or_load'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:61:in `depend_on'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:443:in `require_dependency'
./script/../config/../vendor/rails/actionpack/lib/action_controller/helpers.rb:111:in `default_helper_module!'
./script/../config/../vendor/rails/actionpack/lib/action_controller/helpers.rb:124:in `send'
./script/../config/../vendor/rails/actionpack/lib/action_controller/helpers.rb:124:in `inherited_without_api'
./script/../config/../vendor/rails/actionwebservice/lib/action_web_service/container/action_controller_container.rb:84:in `inherited_without_action_controller'
./script/../config/../vendor/rails/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb:32:in `inherited'
./script/../config/../app/controllers/application.rb:3
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:204:in `load_without_new_constant_marking'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:204:in `load_file'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:343:in `new_constants_in'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:203:in `load_file'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:95:in `require_or_load'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:61:in `depend_on'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:443:in `require_dependency'
./script/../config/../vendor/rails/railties/lib/dispatcher.rb:110:in `prepare_application'
./script/../config/../vendor/rails/railties/lib/dispatcher.rb:39:in `dispatch'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:113:in `handle_dispatch'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:79:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:63:in `dispatch'
./script/../config/../vendor/rails/railties/lib/commands/servers/webrick.rb:59
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in `require'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:343:in `new_constants_in'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in `require'
./script/../config/../vendor/rails/railties/lib/commands/server.rb:39
./script/server:3:in `require'
./script/server:3

Re: Upgrading My App to Rails 1.2.1

You need to fix your config/database.yml file.  It's pointing to your mysql server's socket at /tmp/mysql.sock.  That may not be where it is.  You should google for database.yml + your operating system or use the database.yml file outlined here: http://6brand.com/rails-socket-config-c … ugh-socket

Re: Upgrading My App to Rails 1.2.1

Danger, thank you so much.  Setting the mysqld.sock in the database.yml did the trick. 

BTW, When I goto 6brand.com your styles are messed up really bad in Opera.  But when I click on a post that view is perfect.  So I think your default view has style issues.  Just wanted to let you know if you're not aware.

Thanks again,
-bt

Re: Upgrading My App to Rails 1.2.1

Hey, thanks for the heads up on Opera - I seldom use it to browse my own stuff.  Thanks!

Re: Upgrading My App to Rails 1.2.1

Danger,

  I'm having a similar problem as BigTrouble77.  I have a production Rails application that I want to move to my development machine.  I created a rails app with the same name on my dev box, and I pretty much copied the entire folder from production over.

  When I was attempting to run rake db:schema:load, I got the following error:

  rake aborted!
  getaddrinfo: Name or service not known

  I check my database.yml file.  I even added a path to mysql.sock.  Nothing worked.

  Then I noticed that the production app was done with RAILS_GEM_VERSION = '1.1.6 whereas my dev is running 1.2.1. .  I have since followed the steps you outlined above to upgrade the app to 1.2.1.  It seems that the upgrade went smoothly, but when I run rake db:schema:load, I still get the same error as above.

  Any help would be greatly appreciated.

Thanks

AC

Last edited by anandc77@hotmail.com (2007-03-29 18:10:54)

Re: Upgrading My App to Rails 1.2.1

That error looks like it can't find something on the internet.  Try pinging the mysql host that you have specified in your database.yml file ("ping mysql.myhost.com"), does that work?

You can find out more info from rake by trying:
rake db:schema:load --trace

Re: Upgrading My App to Rails 1.2.1

I can ping it just fine.  It is actually just the local host.  When I tried db:schema:load with trace, it still errors out the same way.

/usr/bin/rake:17:Warning: require_gem is obsolete.  Use gem instead.
(in /var/www/railsapps/sleeter.com)
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
getaddrinfo: Name or service not known


I checked environment.rb and it is the same as evironment.rb on my other rails apps that work fine on the same dev box.  I also tried commenting out the "RAILS_GEM_VERSION =" line as you suggested without any luck.

Re: Upgrading My App to Rails 1.2.1

anandc77@hotmail.com wrote:

I also tried commenting out the "RAILS_GEM_VERSION =" line as you suggested without any luck.

If you comment out that line then you need your copy of rails in the /vendor/rails directory.  I didn't do it this way, but you could probably download rails from the website and uncompress it to that location (I just copied it from where ubuntu installed it).

Re: Upgrading My App to Rails 1.2.1

I think if you comment out the RAILS_GEM_VERSION it will look for the latest version of Rails installed on the system (if it's not in the vendor directory). At least that's how it behaves on my end.

Railscasts - Free Ruby on Rails Screencasts

Re: Upgrading My App to Rails 1.2.1

Thanks everyone.  I don't know what I did, but after I rebooted my box, everything seems to be working.  I really appreciate all the help.

In all liklihood, the rake rails:freeze:edge TAG=rel_1-2-1 is what did it.

Now I have another newbie question.  What I don't get is why did the updated Rails version went into vendor/rails.  Why the vendor folder?

Thanks!

Re: Upgrading My App to Rails 1.2.1

It's because you ran "rake rails:freeze:edge". This freezes the specified Rails version to your project - it doesn't install it in the system. This is why it is placed in your project's vendor directory. Rails uses that folder to hold external resources such as plugins.

Railscasts - Free Ruby on Rails Screencasts

Re: Upgrading My App to Rails 1.2.1

ryanb wrote:

I think if you comment out the RAILS_GEM_VERSION it will look for the latest version of Rails installed on the system (if it's not in the vendor directory). At least that's how it behaves on my end.

I just tested it out again and I think you are right... Previously I was getting an error (if rails wasn't in the vendor directory) in my logs saying it couldn't find rails version 0.0.0.  I did upgrade to 1.2.3 so that may have had something to do with fixing it.