Can't require 'socket' on Windows (JRuby 1.1.5)


#1

I have a JRuby 1.1.5 program that works fine on OS X but I can’t get
it to work on Windows.

When I try to require ‘webrick’ I get the following error:

C:/Program Files/path with
‘quote/java/lib/ruby/1.8/webrick/config.rb:13:in `require’: IO error
– webrick/httputils (LoadError)
from C:/Program Files/path with
'quote/java/lib/ruby/1.8/webrick/config.rb:13

So I started debugging and discovered the real point of failure seems
to be calling
require ‘socket’
which gives the following error:

java.lang.IllegalArgumentException: Neither current working directory
() nor pathname (socket.class) led to an absolute path
at
org.jruby.util.JRubyFile.createNoUnicodeConversion(JRubyFile.java:60)
at org.jruby.util.JRubyFile.create(JRubyFile.java:49)
at
org.jruby.runtime.load.LoadService.tryResourceFromLoadPath(LoadService.java:839)
at
org.jruby.runtime.load.LoadService.tryResourceFromLoadPathOrURL(LoadService.java:754)
at
org.jruby.runtime.load.LoadService.findLibraryWithoutCWD(LoadService.java:631)
at
org.jruby.runtime.load.LoadService.findLibraryWithCWD(LoadService.java:618)
at org.jruby.runtime.load.LoadService.access$200(LoadService.java:122)
at
org.jruby.runtime.load.LoadService$NormalSearcher.trySearch(LoadService.java:388)
at org.jruby.runtime.load.LoadService.smartLoad(LoadService.java:265)
at org.jruby.runtime.load.LoadService.require(LoadService.java:282)
at org.jruby.RubyKernel.require(RubyKernel.java:829)

I have the feeling it’s because of my screwy path that has spaces and
a single quote in it. Unfortunately I have no control over this path.
However, this used to work with JRuby 1.1.2 so maybe something else is
going on.

Any ideas why this is happening and how to work around it? Or how to
debug and get some useful info?

It seems strange the working directory in that
IllegalArgumentException an empty path and it’s doing that
findLibraryWithoutCWD() call. I tried printing out java’s
System.getProperty(“user.dir”) before calling bsf.eval() and it is set
to something reasonable. And I have the following system properties
set:
System.setProperty(“jruby.home”, jRubyHome); // the folder containing
jruby.jar
System.setProperty(“jruby.lib”, jRubyLib); // the parent of the folder
containing jruby.jar
System.setProperty(“jruby.script”, “jruby”);

Any ideas?

Adam


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

Whoops. I have a bug in my setup code and was accidentally calling:
$: << ‘’
(adding the empty string to the LOAD_PATH).

This is because I setup a properties file to allow me to configure
additional directories to put on the LOAD_PATH, and it was defaulting
to the empty string.

Somehow this was causing a problem that only manifests on Windows
later on when I try to require certain libraries.

I investigated further and found that this does not seem to break
anything on OS X or with MRI ruby, so it appears to be some sort of
bug in JRuby on Windows.

I filed an issue: http://jira.codehaus.org/browse/JRUBY-3231

Adam

On Wed, Dec 10, 2008 at 2:43 PM, Adam M. removed_email_address@domain.invalid
wrote:

So I started debugging and discovered the real point of failure seems
at org.jruby.runtime.load.LoadService.findLibraryWithoutCWD(LoadService.java:631)
going on.
System.setProperty(“jruby.home”, jRubyHome); // the folder containing jruby.jar
System.setProperty(“jruby.lib”, jRubyLib); // the parent of the folder
containing jruby.jar
System.setProperty(“jruby.script”, “jruby”);

Any ideas?

Adam


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email