Lenny Marks created JRUBY-6389: ---------------------------------- Summary: TypeError: can't convert Pathname into String - JRuby in 1.9 mode not handling Pathname in $LOAD_PATH consistently with MRI Key: JRUBY-6389 URL: https://jira.codehaus.org/browse/JRUBY-6389 Project: JRuby Issue Type: Bug Affects Versions: JRuby 1.6.5, JRuby 1.6.4 Environment: I'm on OS X 10.6 Java SE 1.6.0_24 (don't think it matters much) Reporter: Lenny Marks Assignee: Thomas E Enebo Attachments: test.rb
$ rvm use jruby Using lenny/.rvm/gems/jruby-1.6.4 $ ruby ./test.rb TypeError: can't convert Pathname into String require at org/jruby/RubyKernel.java:1047 require at lenny/.rvm/rubies/jruby-1.6.4/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29 (root) at lenny/test.rb:3 $ rvm use 1.9.2 Using lenny/.rvm/gems/ruby-1.9.2-p290 bash-3.2$ ruby ./test.rb <internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- foo (LoadError) from <internal:lib/rubygems/custom_require>:29:in `require' from lenny/test.rb:3:in `<main>' Seems like others have run into this, but I didn't find any previous solutions or tickets: http://www.google.com/search?q=TypeError:+can't+convert+Pathname+into+String I ran into this while attempting to port a Rails 3 app from Ruby 1.8.7 to 1.9. Tough to track down because the stack trace is of little help when mixed up with Rails Dependencies loading, but I did eventually pin it at: src/org/jruby/runtime/load/LoadService.java" line 1169 (as of commit a8652d580 Thu Jan 26) RubyString entryString = loadPath.eltInternal(i).convertToString(); In the case of a Pathname in the Loadpath it wound up invoking RubyBaseObject#convertToString // org/jruby/RubyBasicObject.java public RubyString convertToString() { return (RubyString) TypeConverter.convertToType(this, getRuntime().getString(), "to_str"); } This monkey-patch to Pathname cleared it up for me: require 'pathname' Pathname.class_eval do def to_str to_s end end -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email