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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C61cad02bdbddcddee16d48e8af91221?d=identicon&s=25 Adam Murray (Guest)
on 2008-12-10 23:43
(Received via mailing list)
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
C61cad02bdbddcddee16d48e8af91221?d=identicon&s=25 Adam Murray (Guest)
on 2008-12-11 01:42
(Received via mailing list)
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 Murray <adamjmurray@gmail.com>
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
This topic is locked and can not be replied to.