ruby: no such file to load — ubygems (LoadError)

Today when I started my Ruby on Rails application I received this error.

> ruby script/server
ruby: no such file to load -- ubygems (LoadError)

After Googling for this error message I realized somehow my Ruby gems installation was corrupted. I had been planning on upgrading my Ruby from 1.85 to 1.86-26 so now seemed as a good time as ever. 🙂

Fortunately after installing the latest version of Ruby and updating to Ruby on Rails 1.2.6 everything seemed fine.

Upgrading to Rails 1.2.6

Today I upgraded to Rails 1.2.6 as I prepare to move towards Rails 2.0. Notes on this release can be found here.

Here are the steps I took.

  1. Upgrade Ruby Gems to the latest version (in this case 1.0.1).
    gem update --system
  2. Upgrade Ruby on Rails to the latest version (in this case 2.0.2).
    gem install rails
    To specify upgrading to Ruby on Rails 1.2.6 do this.
    gem install rails -v 1.2.6
    (What I probably should have done was a gem update because now I have installed 1.2.6 and 1.2.3.)
  3. Update configuration.
    set RAILS_GEM_VERSION to ‘1.2.6’ in config/environment.rb
    rake rails:update:configs

Deploying to Production Notes

  1. To run the DB migrate scripts you must specify that you are using the production configuration. One simple way to do this is:

    rake RAILS_ENV='production' db:migrate

  2. Make the public/dispatch.* scripts executable. If you developed originally in Windows then you need to change the first line in each of these dispatch scripts from

    #!e:/ruby/bin/ruby

    to

    #!/usr/bin/ruby1.8

  3. Enable FastCGI (CGI is ridiculously slow) by changing .htaccess. Change this line

    RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

    to

    RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

  4. Change the public and log directories to mode 755 (not sure if this is necessary but seems like good practice).

    chmod 755 public
    chmod 755 log

Introduction to Ruby on Rails Presentation

On Tuesday, November 15, 2005 I will be presenting an introduction to Ruby on Rails to the ACM Greater Boston Web Tech Chapter.

The presentation is online. Though it looks like a PowerPoint presentation it’s actually just a single HTML file that is transformed into a PowerPoint-like presentation using CSS and JavaScript provided by Eric Meyer.

Setting up a Windows Ruby on Rails Environment

Ruby

  1. install Ruby using the one click installer
    Note that 1.8.2-15 has a small problem, the Ruby Gems Package Manager shortcut does not work because it is pointing to ruby\bin\gemhelp.cmd which does not exist. To use the Ruby Gems Package Manager open a cmd window and then enter the gems command. Or you can create the gemhelp.cmd file which has only one line in it, cmd /k gem or download it from here.

Ruby on Rails
(see also Getting Started With Rails)

  1. install rails gem (and all its dependencies)
    gem install rails --remote
  2. when doing an upgrade I sometimes had to force it by doing an install of the version I wanted to upgrade to
    gem install --remote --version '0.13.1' rails

Salted Hash Login & Authentication Generator
(see also Salted Login Generator Quick Start)

  1. install salted login generator gem
    gem install --remote salted_login_generator
  2. install localization gem
    gem install --remote localization_generator
  3. Iconv is a library used for charset conversion and required by the Salted Hash Login Generator. Download this iconv package with simple installation instructions, unzip the package, and run the installer.
    C:\tmp\iconv>setup
    Setup has detected Ruby at c:\devel\ruby
    and Windows/System32 at C:\WINDOWS/System32
    Install Iconv there? [yN] y
    cp iconv.so c:\devel\ruby/lib/ruby/1.8/i386-mswin32
    cp iconv.dll C:\WINDOWS/System32
    cp charset.dll C:\WINDOWS/System32
    Installation successful.

    Update, the above iconv package link no longer works. Instead you have to follow the more laborious task of getting iconv.so and installing it in ruby\lib\ruby\1.8\i386-mswin32 and getting iconv.dll and installing it in C:\WINDOWS\System32. More detailed instructions can be found on the iconv in Ruby on Rails page.

RMagick
(see also RMagick Install FAQ)

  1. download latest RMagick Windows gem ZIP archive from http://rubyforge.org/projects/rmagick/
  2. unzip Windows gem archive
  3. go into unzipped directory and do a local gem install
    C:\tmp\RMagick-1.9.1-IM-6.2.3-win32>gem install RMagick-win32-1.9.2-mswin32.gem
  4. run post installer
    C:\tmp\RMagick-1.9.1>postinstall
    RMagick 1.9.2 win32 Post Installation (see enclosed README for license information)
    detecting available fonts, writing to config/type-windows.xml...ok.
    setting MAGICK_CONFIGURE_PATH to 'c:/devel/ruby/lib/ruby/gems/1.8/gems/RMagick-win32-1.9.2-mswin32/config'.
    setting is only for current user.
    Copying 5 dlls to c:/devel/ruby/bin...done.
    all done.

MySQL

  1. install MySQL 4.1 (use the Windows Essential installer)
  2. create tables, for example
    mysql -u fkim -p < zipcodes.sql

phpMyAdmin
Excellent web based MySQL administration tool.

  1. download phpMyAdmin package
  2. unzip package and configure Apache to locate that package
  3. I use phpMyAdmin for administration tasks such as creating users and database