Mysterious TextMate/Edge Rails/open_id_authentication error

Rails Experts,

I have run into an interesting problem with TextMate, its Rails bundle, Edge Rails and the open_id_authentication plugin. When I have these components installed, the “Call Generate Script” command stops working in TextMate, giving only a blank dialog in response to model creation requests.

I have a setup like Robby (http://www.robbyonrails.com/articles/2007/06/19/installing-ruby-on-rails-and-postgresql-on-os-x-second-edition
) but with mysql rather than postgresql. Below is a log of how I’ve managed to reproduce the issue from scratch in a terminal window without TextMate involvement, while still mimicking what TextMate is doing.

First, I check out edge rails and create a rails project using edge rails’ rails command, then check out edge rails into vendor/rails. In order to make the example short, I bypass creating databases and I comment out a statement in environment.rb that would otherwise give an error and distract from what I’m trying to show. Then I set the RUBYLIB environment variable to the same value as what TextMate sets it to by prepending and appending the same paths as TextMate does when running the “Call Generate Script” from the Rails bundle. The “about” script is giving the same error as the “generate” script so I’ve used it in my example for simplicity’s sake. After checking out the latest revision of the open_id_authentication plugin I run the “about” script again and BOOM! there’s an error. After much debugging I found that by simply moving the redcloth.rb file from the Rails bundle out of the way, everything starts working again. I then move the file back again and go on to show that the issue was introduced in edge rails revision 6833. Finally, I set the RUBYLIB environment variable back to its original value and run the “about” script successfully.

Now, what is puzzling to me is that the changes in revision 6833 and having the redcloth.rb file in the RUBYLIB path seem to be irrelevant to what I am trying to do, which is to run the “about” and “generate” scripts. I suppose there is some class loading issue going on here.

For what it’s worth, I have also tried updating to the latest TextMate Support and Rails bundles via svn, but with the same end result. For now, I have just renamed the redcloth.rb file in the Rails bundle and I’m able to use the “generate” command from within TextMate. I suppose I could also just use the “generate” command from a terminal window, but I like that less because of its minor productivity loss.

Is there a TextMate/Rails expert out there who can tell where the issue should be fixed (Rails bundle, or Edge Rails?) and what is really causing the issue?

Peter

$ env | grep RUBYLIB
RUBYLIB=/opt/local/lib/ruby/site_ruby/1.8:/opt/local/lib/ruby/1.8

$ export ORIGINAL_RUBYLIB=$RUBYLIB

$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.10.1]

$ rails -v
Rails 1.2.3

$ gem -v
0.9.4

$ rake --version
rake, version 0.7.3

$ svn co http://svn.rubyonrails.org/rails/trunk rails

$ ruby rails/railties/bin/rails test

$ rm -rf rails

$ cd test

comment out the following in config/environment.rb:

config.action_controller.session = {

:session_key => ‘_test_session’,

:secret => ‘41acd5825f0415b50cb6d70ca041e393’

}

$ export RUBYLIB=/Applications/TextMate.app/Contents/SharedSupport/Bundles/Rails.tmbundle/Support/lib:$RUBYLIB:/Applications/TextMate.app/Contents/SharedSupport/Support/lib

$ svn co http://svn.rubyonrails.org/rails/trunk vendor/rails

$ script/about
About your application’s environment
Ruby version 1.8.6 (i686-darwin8.10.1)
RubyGems version 0.9.4
Rails version 1.2.3
Active Record version 1.15.3
Action Pack version 1.13.3
Action Web Service version 1.2.3
Action Mailer version 1.3.3
Active Support version 1.4.2
Edge Rails revision 7271
Application root /Users/cph/work/test
Environment development
Database adapter mysql

$ svn co
http://svn.rubyonrails.org/rails/plugins/open_id_authentication
vendor/plugins/open_id_authentication

$ script/about
/Users/cph/work/test/vendor/plugins/open_id_authentication/init.rb:5:in evaluate': undefined method gem’ for #Rails::Plugin::Loader:0x251cf50 (NoMethodError)

    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:107:in `evaluate'
    from /Users/cph/work/test/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'

    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:107:in `evaluate'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:24:in `load'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:183:in `load_plugins'

    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/locator.rb:16:in `each'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/locator.rb:16:in `each'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:182:in `load_plugins'

     ... 6 levels...
    from /Users/cph/work/test/vendor/rails/railties/lib/commands/about.rb:1:in `require'
    from /Users/cph/work/test/vendor/rails/railties/lib/commands/about.rb:1
    from script/about:3:in `require'

    from script/about:3

$ mv /Applications/TextMate.app/Contents/SharedSupport/Support/lib/redcloth.rb /Applications/TextMate.app/Contents/SharedSupport/Support/lib/redcloth.rb.bak

$ script/about
About your application’s environment
Ruby version 1.8.6 (i686-darwin8.10.1)
RubyGems version 0.9.4
Rails version 1.2.3
Active Record version 1.15.3
Action Pack version 1.13.3
Action Web Service version 1.2.3
Active Resource version 0.9.0
Action Mailer version 1.3.3
Active Support version 1.4.2
Edge Rails revision 7271
Application root /Users/cph/work/test

Environment development
Database adapter mysql

$ mv /Applications/TextMate.app/Contents/SharedSupport/Support/lib/redcloth.rb.bak /Applications/TextMate.app/Contents/SharedSupport/Support/lib/redcloth.rb

$ svn up -r6832 vendor/rails

$ script/about
About your application’s environment
Ruby version 1.8.6 (i686-darwin8.10.1)
RubyGems version 0.9.4
Rails version 1.2.3
Active Record version 1.15.3
Action Pack version 1.13.3
Action Web Service version 1.2.3
Action Mailer version 1.3.3
Active Support version 1.4.2
Edge Rails revision 6832

Application root /Users/cph/work/test
Environment development
Database adapter mysql

$ svn up -r6833 vendor/rails

$ script/about
/Users/cph/work/test/vendor/plugins/open_id_authentication/init.rb:5:in evaluate': undefined method gem’ for #Rails::Plugin::Loader:0x2535d20 (NoMethodError)

    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:107:in `evaluate'
    from /Users/cph/work/test/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'

    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:107:in `evaluate'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:24:in `load'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:193:in `load_plugins'

    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/locator.rb:16:in `each'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/locator.rb:16:in `each'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:192:in `load_plugins'

     ... 6 levels...
    from /Users/cph/work/test/vendor/rails/railties/lib/commands/about.rb:1:in `require'
    from /Users/cph/work/test/vendor/rails/railties/lib/commands/about.rb:1
    from script/about:3:in `require'

    from script/about:3

$ export RUBYLIB=$ORIGINAL_RUBYLIB

$ script/about
About your application’s environment
Ruby version 1.8.6 (i686-darwin8.10.1)
RubyGems version 0.9.4
Rails version 1.2.3
Active Record version 1.15.3
Action Pack version 1.13.3
Action Web Service version 1.2.3
Action Mailer version 1.3.3
Active Support version 1.4.2
Edge Rails revision 6833
Application root /Users/cph/work/test
Environment development
Database adapter mysql