Forum: JRuby Resolv Doesn't Work in JRuby?

Posted by Keith B. (keith_b)
on 2013-01-04 21:53
(Received via mailing list)
All -

Can anyone explain why Resolv.getaddress would not work in JRuby?

Some commands and their output to illustrate are at 
https://gist.github.com/4455902.

Thanks,
Keith


---
Keith R. Bennett
http://about.me/keithrbennett
Posted by Hassan Schroeder (Guest)
on 2013-01-04 22:24
(Received via mailing list)
On Fri, Jan 4, 2013 at 12:52 PM, Keith Bennett <keithrbennett@gmail.com> 
wrote:

> Can anyone explain why Resolv.getaddress would not work in JRuby?

I just tried your example with JRuby 1.7.0, 1.7.1, and 1.7.2 and it
worked identically -- i.e. successfully -- to MRI.

(With Mac OS java version "1.6.0_37")

Not sure what to suggest  :-/

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Posted by Rohit Namjoshi (Guest)
on 2013-01-04 23:54
(Received via mailing list)
Works for me too on 1.7.1. Ubuntu 10.04.4 LTS, java version "1.6.0_26"

On Fri, Jan 4, 2013 at 3:21 PM, Hassan Schroeder 
<hassan.schroeder@gmail.com
Posted by Keith B. (keith_b)
on 2013-01-05 07:40
(Received via mailing list)
Wow, this is really weird.  I tried it on 2 Macs (both running Mountain 
Lion), 1 Linux box, a Linux VM, with bash and zsh, Java 1.6 and 1.7, 
JRuby 1.7.0 and 1.7.1, with my cable and cell phone Internet 
connections, and could not get it to work on any.  Interestingly, the 
error I got on 1.7.0 was different from 1.7.1.  On 1.7.0 I got this (see 
https://gist.github.com/4459936):
SocketError: recv: name or service not known
All JRuby installations were rvm installations.

I'm looking forward to 1.7.2 being supported by rvm so I can test that. 
Does anyone know if I can install from the tar file and easily uninstall 
it later?

Thanks,
Keith

---
Keith R. Bennett
http://about.me/keithrbennett
Posted by Alex Tambellini (Guest)
on 2013-01-05 07:43
(Received via mailing list)
If you run "rvm get stable" that should allow you to install jruby 
1.7.2.
Posted by Keith B. (keith_b)
on 2013-01-05 07:58
(Received via mailing list)
Alex -

Thanks for that!  I wouldn't have expected that the known rubies would 
be hard coded into the local rvm installation and not discoverable over 
the Internet. (Is that the case?)

I did indeed install it, and got the same error with 1.7.2.  The error I 
got was the same as 1.7.0, so the message I described before as a 1.7.0 
message was really the Linux error message, I think.

Tried 1.7.2 on Mac OS and Linux.  Same error.

- Keith

---
Keith R. Bennett
http://about.me/keithrbennett
Posted by Claus Folke Brobak (cfbrobak)
on 2013-01-05 08:39
Keith B. wrote in post #1091075:
> All -
>
> Can anyone explain why Resolv.getaddress would not work in JRuby?
>
> Some commands and their output to illustrate are at
> https://gist.github.com/4455902.
>

Just pointing out that you are executing "ruby" and not "jruby" in your
examples. However, I am not familiar with "rvm" so being able to do this
may be a feature in that product.

/Claus
Posted by kristian (Guest)
on 2013-01-05 14:31
(Received via mailing list)
what about just trying jruby without rvm - since it works with me
using jruby-complete.jar jars.

- Kristian
Posted by Keith B. (keith_b)
on 2013-01-05 16:09
(Received via mailing list)
Claus -

rvm maps the standard Ruby and Rails executables (ruby, irb, rake, gem, 
rails) to their JRuby equivalents so that you can treat JRuby and other 
Rubies identically.  That's one of the things I love about it -- no more 
need for jruby or jruby -S command_name:

[1] 10:03 mbp-15 /Users/keithb/.rvm/rubies/jruby/lib
>rvm jruby

[0] 10:03 mbp-15 /Users/keithb/.rvm/rubies/jruby/lib
>ruby -v
jruby 1.7.2 (1.9.3p327) 2013-01-04 302c706 on Java HotSpot(TM) 64-Bit 
Server VM 1.6.0_37-b06-434-11M3909 [darwin-x86_64]

You can check it out at https://rvm.io/ if you want.  It only works on 
Unix-based OS's though.

- Keith

---
Keith R. Bennett
http://about.me/keithrbennett
Posted by Hassan Schroeder (Guest)
on 2013-01-05 17:02
(Received via mailing list)
On Fri, Jan 4, 2013 at 10:38 PM, Keith Bennett <keithrbennett@gmail.com> 
wrote:

> All JRuby installations were rvm installations.
>
> I'm looking forward to 1.7.2 being supported by rvm so I can test that.

I should mention that my successful tests using 1.7.0, 1.7.1, and
1.7.2 were all using rvm on Mac. So I don't think that's relevant.

You can always do a simple install by untarring and setting up
symlinks and/or PATH values to use that version. That's how I
worked before rvm :-)

FWIW,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Posted by Keith B. (keith_b)
on 2013-01-06 00:22
(Received via mailing list)
I am stumped on this, and have spent way more time on it than I wanted 
to.  A StackOverflow message suggested using IPSocket.getaddress 
instead, and it works perfectly, so that's what I'm going to use:

>rvm jruby

>ruby -e "require 'socket'; puts IPSocket.getaddress 'cnn.com'"
157.166.226.25

- Keith

---
Keith R. Bennett
http://about.me/keithrbennett
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.