My Profile Photo

rubycoloredglasses


I'm Jason, a web applications developer in the San Francisco Bay area.


Using Rails 2.3.8

I’m working on a project that is stuck on Rails 2.3.8 due to the size and complexity of the codebase. Upgrading it would be a nightmare. I recently ran into an issue with the database_cleaner gem, which isn’t rolling back transactional queries properly. I’m not sure if the issue is with the gem, or perhaps some configuration with the system (ActiveRecord) which is causing the issue. Because of this, I’m wanting to create a dummy Rails 2.3.8 application so that I can reproduce the issue on a fresh, simple, vanilla Rails application.

I created a new ‘rails238’ directory and switched to it, then created a new gemset via RVM.

rvm --rvmrc --create 1.8.7@rails238

I then installed Rails 2.3.8.

gem install --version '2.3.8' rails

After this finished, I ran into an error when I would try to create a new Rails app.


$ rails -d mysql funtownauto

/Users/jsmith/.rvm/gems/ruby-1.8.7-p371@rails238/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:55: uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)
    from /Users/jsmith/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    from /Users/jsmith/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from /Users/jsmith/.rvm/gems/ruby-1.8.7-p371@rails238/gems/activesupport-2.3.8/lib/active_support.rb:57
    from /Users/jsmith/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    from /Users/jsmith/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from /Users/jsmith/.rvm/gems/ruby-1.8.7-p371@rails238/gems/rails-2.3.8/lib/rails_generator.rb:31
    from /Users/jsmith/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    from /Users/jsmith/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from /Users/jsmith/.rvm/gems/ruby-1.8.7-p371@rails238/gems/rails-2.3.8/bin/rails:15
    from /Users/jsmith/.rvm/gems/ruby-1.8.7-p371@rails238/bin/rails:19:in `load'
    from /Users/jsmith/.rvm/gems/ruby-1.8.7-p371@rails238/bin/rails:19
    from /Users/jsmith/.rvm/gems/ruby-1.8.7-p371@rails238/bin/ruby_noexec_wrapper:14

This was resolved by downgrading the default Rubygems to version 1.4.2.

gem update --system 1.4.2

I ran through the instructions to setup Bundler with a Rails 2.3.8 system, manually created the ‘Gemfile’ in the root directory of the project, then ran ‘bundle install’.

This included RSpec for Rails 1.3.4.

source :rubygems

gem 'rails', '2.3.8'
gem 'mysql2', '~> 0.2.11'
gem 'rdoc'
gem 'bundler'

group :development, :test do
  gem 'rspec', '~> 1.3.2'
  gem 'rspec-rails', '~> 1.3.4'
  gem 'database_cleaner', '0.8.0'
  gem 'fabrication', '~> 1.3.2'
end

I installed Rspec, then tried to list the rake tasks available, I would receive an error regarding RDoc.


$ script/generate rspec
Configuring rspec and rspec-rails gems in config/environments/test.rb ...
      exists  lib/tasks
      create  lib/tasks/rspec.rake
      create  script/autospec
      create  script/spec
      create  spec
      create  spec/rcov.opts
      create  spec/spec.opts
      create  spec/spec_helper.rb
$ be rake -T | grep spec

rake aborted!
no such file to load -- rake/rdoctask
/Users/jsmith/Documents/rails238/funtownauto/Rakefile:8:in `require'
/Users/jsmith/Documents/rails238/funtownauto/Rakefile:8
/Users/jsmith/.rvm/gems/ruby-1.8.7-p371@rails238/bin/ruby_noexec_wrapper:14
(See full trace by running task with --trace)

It turns out that the config in the Rakefile conflicts with the latest Rdoc (version 3.12). I had to replace “require ‘rake/rdoctask’” with:

require 'rdoc/task'

This resolved the rake issue.

require 'rdoc/task'

Now I try to run the default Rspec test script, but run into an issue with the MySQL gem.

$ bundle exec rake spec
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.

rake aborted!
no such file to load -- mysql
/Users/jsmith/.rvm/gems/ruby-1.8.7-p371@rails238/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
/Users/jsmith/.rvm/gems/ruby-1.8.7-p371@rails238/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
/Users/jsmith/.rvm/gems/ruby-1.8.7-p371@rails238/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in
/Users/jsmith/.rvm/gems/ruby-1.8.7-p371@rails238/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'

Still stuck on this issue with the MySQL gem. I have MySQL2 gem installed, which works on the other non-new project, but still this error persists. This Stackflow article seems related, but the suggested solutions don’t help.