Jruby and gems

Dear all,

I am having trouble loading a gem in Jruby, Ubuntu 8.04 persistently says it can't find it:

/usr/local/jruby-1.1.3/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require': no such file to load -- profligacy/swing (LoadError)

swing.rb is here on my system:

/usr/local/jruby-1.1.3/samples/minijava/swing.rb
/usr/local/profligacy-1.0/lib/profligacy/swing.rb
/usr/local/lib/ruby/gems/1.8/gems/profligacy-1.0-java/lib/profligacy/swing.rb

···

------------------------------------------------------------------------------------

It tried changing the PATH variable in .bashrc, but still, it doesn't work.

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/jruby-1.1.3/bin

Is there something special that one has to do in JRuby to find gems ?

Below is the text of the script causing the error:

require "rubygems"
require 'java'
require 'profligacy/swing'

import 'javax.swing.JFrame'
import 'javax.swing.JLabel'

class SwingDemo
  def initialize
    jfrm = JFrame.new "A Simple Demo"
    jfrm.setSize(275,100)
    jfrm.default_close_operation = JFrame::EXIT_ON_CLOSE
    jlab = JLabel.new " Swing powers the modern Java GUI"
    jfrm.add jlab
    jfrm.pack
    jfrm.visible = true
  end
end

SwingUtilities.invoke_later proc { SwingDemo.new }.to_runnable
-----------------------------------------------------------------------------------------------------

Thank you very much for your help.

Best regards,

Axel
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

PATH doesn't have any effect on gems, but GEM_HOME and GEM_PATH do. Do
you by chance have either of those set in your environment?

/Nick

···

On Wed, Aug 20, 2008 at 10:06 AM, Axel Etzold <AEtzold@gmx.de> wrote:

Dear all,

I am having trouble loading a gem in Jruby, Ubuntu 8.04 persistently says it can't find it:

/usr/local/jruby-1.1.3/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require': no such file to load -- profligacy/swing (LoadError)

swing.rb is here on my system:

/usr/local/jruby-1.1.3/samples/minijava/swing.rb
/usr/local/profligacy-1.0/lib/profligacy/swing.rb
/usr/local/lib/ruby/gems/1.8/gems/profligacy-1.0-java/lib/profligacy/swing.rb

------------------------------------------------------------------------------------

It tried changing the PATH variable in .bashrc, but still, it doesn't work.

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/jruby-1.1.3/bin

Is there something special that one has to do in JRuby to find gems ?

Axel,
Ruby's gems and JRuby's gems are normally not in the same location. I believe JRuby uses jgem now. If not, you can symlink your gem script to jgem. Make sure that profligacy is installed with jgem install profligacy (or whatever the name of the gem is). It's common for myself and those at the office to mix this up and we've had a few of the Monkeybars users experience the same issue.

By the way, if get a chance, I'd look at Monkeybars for JRuby GUI development: http://monkeybars.rubyforge.org/
We're still keeping watch over it, and you can also find us on freenode in #monkeybars if you need any help.

-Logan

···

On Aug 20, 2008, at 8:06 AM, Axel Etzold wrote:

Dear all,

I am having trouble loading a gem in Jruby, Ubuntu 8.04 persistently says it can't find it:

/usr/local/jruby-1.1.3/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require': no such file to load -- profligacy/swing (LoadError)

swing.rb is here on my system:

/usr/local/jruby-1.1.3/samples/minijava/swing.rb
/usr/local/profligacy-1.0/lib/profligacy/swing.rb
/usr/local/lib/ruby/gems/1.8/gems/profligacy-1.0-java/lib/profligacy/swing.rb

------------------------------------------------------------------------------------

It tried changing the PATH variable in .bashrc, but still, it doesn't work.

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/jruby-1.1.3/bin

Is there something special that one has to do in JRuby to find gems ?

hi all !!!
I had resolved this problem!"no such file to load -- profligacy/swing
(LoadError)"
please copy
"ruby1\jruby-1.0.2\lib\ruby\gems\1.8\gems\profligacy-1.0-jruby\lib\profligacy\"
to your application directory,because I need all of files when deploy my
application.so ,everything is ok!!!

brucewata

···

--
Posted via http://www.ruby-forum.com/.

> Is there something special that one has to do in JRuby to find gems ?

PATH doesn't have any effect on gems, but GEM_HOME and GEM_PATH do. Do
you by chance have either of those set in your environment?

/Nick

Dear Nick,

thank you for responding. Actually, I didn't set GEM_HOME or GEM_PATH.
Before I do, can you tell me whether setting these for JRuby gems will interfere
with gems for MRI ?
The profligacy gem is the first jruby gem I have installed, but I have quite
a few MRI gems installed, which could be found without problems so far.

Thank you,

Best regards,

Axel

···

--
GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!

Logan Barnett wrote:

Dear all,

I am having trouble loading a gem in Jruby, Ubuntu 8.04 persistently says it can't find it:

By the way, if get a chance, I'd look at Monkeybars for JRuby GUI development: http://monkeybars.rubyforge.org/
We're still keeping watch over it, and you can also find us on freenode in #monkeybars if you need any help.

And you can certainly stop by #jruby as well for assistance getting the gems working. My guess is that this may be a problem with how JRuby is installed.

- Charlie

···

On Aug 20, 2008, at 8:06 AM, Axel Etzold wrote:

That's good. I recommend to leave them unset -- I was asking just in
case that was getting in the way of success.

How are you launching your program?

/Nick

···

On Wed, Aug 20, 2008 at 10:22 AM, Axel Etzold <AEtzold@gmx.de> wrote:

> Is there something special that one has to do in JRuby to find gems ?

PATH doesn't have any effect on gems, but GEM_HOME and GEM_PATH do. Do
you by chance have either of those set in your environment?

/Nick

Dear Nick,

thank you for responding. Actually, I didn't set GEM_HOME or GEM_PATH.
Before I do, can you tell me whether setting these for JRuby gems will interfere
with gems for MRI ?
The profligacy gem is the first jruby gem I have installed, but I have quite
a few MRI gems installed, which could be found without problems so far.

-------- Original-Nachricht --------

Datum: Thu, 21 Aug 2008 00:29:42 +0900
Von: "Nick Sieger" <nicksieger@gmail.com>
An: ruby-talk@ruby-lang.org
Betreff: Re: Jruby and gems

>
>> > Is there something special that one has to do in JRuby to find gems ?
>>
>> PATH doesn't have any effect on gems, but GEM_HOME and GEM_PATH do. Do
>> you by chance have either of those set in your environment?
>>
>> /Nick
>
> Dear Nick,
>
> thank you for responding. Actually, I didn't set GEM_HOME or GEM_PATH.
> Before I do, can you tell me whether setting these for JRuby gems will
interfere
> with gems for MRI ?
> The profligacy gem is the first jruby gem I have installed, but I have
quite
> a few MRI gems installed, which could be found without problems so far.

That's good. I recommend to leave them unset -- I was asking just in
case that was getting in the way of success.

How are you launching your program?

/Nick

Nick,

in a terminal, I type

jruby <scriptname>

Best regards,

Axel

···

On Wed, Aug 20, 2008 at 10:22 AM, Axel Etzold <AEtzold@gmx.de> wrote:

--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: GMX Handytarife 2024 | jetzt wechseln & sparen

Sorry, I can't think of anything else that could be wrong, other than
to make sure that you are running the correct JRuby (do you have more
than one installed) or to simply try again from a fresh JRuby install
and re-install the profligacy gem. Everything else you have (in the
script and on the filesystem) looks correct.

/Nick

···

On Wed, Aug 20, 2008 at 10:34 AM, Axel Etzold <AEtzold@gmx.de> wrote:

How are you launching your program?

/Nick

Nick,

in a terminal, I type

jruby <scriptname>

jruby <scriptname>

And to install the gem, did you type
/opt/jruby/bin/gem install profligacy
?

-------- Original-Nachricht --------

Datum: Thu, 21 Aug 2008 01:46:28 +0900
Von: Mark Thomas <ruby@thomaszone.com>
An: ruby-talk@ruby-lang.org
Betreff: Re: Jruby and gems

> jruby <scriptname>

And to install the gem, did you type
/opt/jruby/bin/gem install profligacy
?

Dear Nick, Logan, Charles and Mark,

thank you for your responses.

Charles:

And you can certainly stop by #jruby as well for assistance getting the
gems working. My guess is that this may be a problem with how JRuby is
installed.

- Charlie

I re-installed jruby from source, untarring file jruby-1.1.3.tar.gz with ant (as done previously).
These are some of my data (all on Ubuntu 8.04):

axel@alecrim:~$ java -version
java version "1.6.0_0"
OpenJDK Runtime Environment (build 1.6.0_0-b11)
OpenJDK Server VM (build 1.6.0_0-b11, mixed mode)
axel@alecrim:~$ jruby -version
jruby 1.1.3 (ruby 1.8.6 patchlevel 114) (2008-08-20 rev 6586) [i386-java]
-e:1: undefined local variable or method `rsion' for main:Object (NameError)
axel@alecrim:~$ jruby --version
jruby 1.1.3 (ruby 1.8.6 patchlevel 114) (2008-08-20 rev 6586) [i386-java]

Logan:

Axel,
Ruby's gems and JRuby's gems are normally not in the same location.

That's why I wouldn't want to mess with gem path variables without asking :slight_smile:

I believe JRuby uses jgem now. If not, you can symlink your gem script
to jgem. Make sure that profligacy is installed with jgem install
profligacy (or whatever the name of the gem is). It's common for
myself and those at the office to mix this up and we've had a few of
the Monkeybars users experience the same issue.

Mark:

I had used some other command the author of the gem gave me. I went
to the jruby directory, and used the "gem install" command from there.
It is not an /opt/jruby etc. directory, as I don't have one, but it is a jruby
command rather than an MRI one.

Now I tried installing with jgem also:
Now, if I go to the the directory where jgem is, it gives me this error:

root@alecrim:/usr/local/jruby-1.1.3/bin# ./jgem /usr/local/profligacy*gem
/usr/bin/env: jruby: No such file or directory

Otherwise, calling jruby works ....

axel@alecrim:~$ jruby j.rb
value: Bar
value: baz
value: foo
axel@alecrim:~$ cat j.rb
require 'java'
include_class 'java.util.TreeSet'
set = TreeSet.new
set.add "foo"
set.add "Bar"
set.add "baz"
set.each do |v|
  puts "value: #{v}"
end

I'll definitely also have a look at Monkeybars, but that software will have to find java's swing also...
so I'd like to be able to use this gem here....

Thank you for your help!

Best regards,

Axel

···

--
Psssst! Schon das coole Video vom GMX MultiMessenger gesehen?
Der Eine für Alle: GMX Produkte Übersicht: Apps, Browser, MailCheck und Co.

Axel,
Monkeybars is one of the three JRuby/Swing frameworks out there. Profligacy and Cherri are the other two.
The main distinction that I'm aware of is that Profilgacy and Cherri wrap Swing for you, and expose a Ruby-friendly API for accessing Swing. Monkeybars is different in that it provides a sort of landing pad for Swing (the view), where you can do all of your nitty gritty Swing stuff. While there are helpers for Swing, you are still directly exposed to it.

I'm not sure if you're running an existing Swing project or not, but Monkeybars is supposed to integrate into existing Java apps (Monkeybars itself provides a jar). However, I'm not aware of any apps like this in the wild.

Finally, my concern is that, to my awareness, Profligacy and Cherri aren't maintained anymore.

-Logan

···

On Aug 20, 2008, at 10:51 AM, Axel Etzold wrote:

I'll definitely also have a look at Monkeybars, but that software will have to find java's swing also...
so I'd like to be able to use this gem here....

Axel Etzold wrote:

I re-installed jruby from source, untarring file jruby-1.1.3.tar.gz with ant (as done previously).
These are some of my data (all on Ubuntu 8.04):

axel@alecrim:~$ java -version
java version "1.6.0_0"
OpenJDK Runtime Environment (build 1.6.0_0-b11)
OpenJDK Server VM (build 1.6.0_0-b11, mixed mode)
axel@alecrim:~$ jruby -version
jruby 1.1.3 (ruby 1.8.6 patchlevel 114) (2008-08-20 rev 6586) [i386-java]
-e:1: undefined local variable or method `rsion' for main:Object (NameError)
axel@alecrim:~$ jruby --version
jruby 1.1.3 (ruby 1.8.6 patchlevel 114) (2008-08-20 rev 6586) [i386-java]

Try "jruby -S gem install profligacy" and stop by #jruby if it still doesn't work. Seem like it's just a setup issue.

- Charlie

This means that env can't find jruby. You're likely to have problems
with all scripts that you try to run without specifying jruby first. I
recommend putting jruby in your path so that env can find it.

···

On Aug 20, 1:51 pm, Axel Etzold <AEtz...@gmx.de> wrote:

root@alecrim:/usr/local/jruby-1.1.3/bin# ./jgem /usr/local/profligacy*gem
/usr/bin/env: jruby: No such file or directory