Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.4, JRuby 1.6.5
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: None
-
Labels:None
-
Environment:I'm on OS X 10.6 Java SE 1.6.0_24 (don't think it matters much)
-
Testcase included:yes
-
Number of attachments :
Description
$ 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
I'm definitely seeing this as well; it's present in 1.6.7 (jruby --1.9 fail_app.rb) and in 1.7.0.
# -*- ruby encoding: utf-8 -*- require 'pathname' SOURCE = Pathname.new(__FILE__).dirname $:.unshift SOURCE.join('lib') require 'fail_require'