Any JRUBY programmers out there? Problems specifying RUBYLIB with jruby.

R

Ronald Fischer

I would like to run jruby on either pure Windows, or Cygwin. This works
fine as long as I
only use the standard library which comes with jruby. I can't make it,
however, search
additional libraries I have put in non-standard places. For example, I
have a Ruby module
placed in ....\SOMEPATH\lib\net\ssh, which I require from my Ruby
program by

require 'net/ssh'=20

I guess I have now to set my RUBYLIB environment variable, so that jruby
can resolve the
require statement. I tried several possible variations of how to set
RUBYLIB, but always
get a "no such file to load".=20

For example under cygwin (bash shell), even a

cd SOMEPATH # go to the directory containing the library
RUBYLIB=3D. jruby MYPROGRAM.rb

or

RUBYLIB=3Dlib jruby MYPROGRAM.rb

does not find the library. And in a Windows command shell,

set RUBYLIB=3D....\SOMEPATH\lib\net\ssh

or, respectively,

set RUBYLIB=3D....\SOMEPATH\lib\net\ssh\lib

doesn't make jruby find the library either.

I would already be glad finding a solution for either Windows or Cygwin,
but of
course being able to get it running under both would be even better. I
understand
that doing it for Cygwin is trickier though, because Jruby is based on
Java and
hence doesn't understand Cygwin pathes.

Ronald

--=20
Ronald Fischer <[email protected]>
Phone: +49-89-452133-162
=20
 
R

Ronald Fischer

Ok, what you should do here is not use RUBYLIB at all. JRuby does=20
understand RUBYLIB, but it won't do what you expect. Instead,=20
use the -I=20
parameter to JRuby:
=20
jruby -I lib MYPROGRAM.rb
=20
This will work just fine on both Win32 and Cygwin.

Thank you very much.

Ronald
 
S

Scott Miller

I currently use RUBYLIB in a similar way. It's especially handy for
one-off command-line scripts:

bashrc -
export RUBYLIB=c:/cvs-main/db-building/scripts

...

ruby -e "require 'lsml'; $p.parse{ |r| r.ids.each {|id| if id.type ==
'reg' then puts id end}}" file.xml

where the lsml library has a bunch of pre-canned tools set up. It would
be a drag to have to specify -I ... every time.

The problem I ran into with jruby is that it doesn't know about the
cygwin mounts (/cygdrive/c/) and splits on ":" instead of ";" - which
makes the c:/ notation problematic. (Incidentally, the cygwin ruby
handles both ; and : in RUBYLIB)

I posted a fix to jira - where it uses File.pathSeparator instead of :,
and have been happy ever since.

http://jira.codehaus.org/browse/JRUBY-938


Ola - I'm left curious as to what RUBYLIB is supposed to do, if not
handle this case, and if so, is there another (perhaps more appropriate)
way to do what I'm suggesting?

Thanks,
Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top