This project is archived and is in readonly mode.

#2130 ✓committed
Jeff Schwab

plugin.rb incompatibility with Ruby 1.9

Reported by Jeff Schwab | March 4th, 2009 @ 08:11 PM | in 2.x

railties/lib/commands/plugin.rb uses the method "reject" on a String, but String no longer has this method in Ruby 1.9 (since String is no longer Enumerable).

The attached patch adds a call to String#lines, per the suggestion at:

The error message is of the form: plugin.rb:137:in externals': undefined methodreject' for "":String (NoMethodError)

I've been trying to submit a patch through git for the past two days, but can't even get rails test to work out of the box. Relevant threads are at:

Comments and changes to this ticket

  • Matt Jones

    Matt Jones March 4th, 2009 @ 08:52 PM

    • Tag changed from patch to patch, ruby1.9

    This patch still needs some work - note that String#lines is not defined for RUBY_VERSION < 1.9. Given the current speed of the migration effort, Ruby 1.8 support is needed. I'd recommend that you revise the patch in the spirit of line 904 of plugin.rb:

        @urls_to_fetch = RUBY_VERSION >= '1.9' ? urls_to_fetch.lines : urls_to_fetch.to_a

    ..which will work correctly on both 1.9 and 1.8.

    Either that, or you could use an approach like this:

    lines = str.send(str.respond_to?(:lines) ? :lines : :to_s).to_a

    (from this blog post )

  • Jeff Schwab

    Jeff Schwab March 4th, 2009 @ 09:48 PM

    Thanks for the gentle treatment of my rookie mistake. An updated patch is attached.

    In other codebases, I would include a comment, explaining what I did and why, and referring to this bug report. I see that there are no other such comments in the file, so I guess they only go in the version control logs. Here is a "starter" log entry:

    Ruby 1.8 strings are Enumerable, but do not support :lines. In Ruby 1.9, the situation is reversed.

  • Jeff Schwab
  • Pratik

    Pratik March 9th, 2009 @ 12:58 PM

    • Assigned user set to “Jeremy Kemper”
  • Repository

    Repository March 10th, 2009 @ 06:58 PM

    • State changed from “new” to “committed”

    (from [e609d83f1a7f49bf8a9549c480a67ee045950336]) Fixed an incompatibility with Ruby 1.9.

    Ruby 1.8 strings are Enumerable, but there is no String#lines method. In Ruby 1.9, the situation is reversed. To work around this disparity, the RailsEnvironment#externals method now explicitly checks whether a String responds_to? :lines.

    [#2130 state:committed]

    Signed-off-by: Jeremy Kemper

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>



Referenced by