[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Why does drb.rb depend on its filename?

Jay Levitt

2/19/2006 12:53:00 AM

I was creating my first DRb server, and ran into a trouble with ACLs. I
wanted to put a debug statement into DRb::Accept, so I copied it to my
directory, renamed it jrb.rb, and required it with the new name. But when
I did that, I got an error at launch:

....jrb.rb:1047: undefined method `to_s' for class `DRb::DRbObject'
(NameError)

And the same error happened when I left jrb.rb in /usr/local/lib/ruby/1.8.
So it's not the path - it's the filename.

What's going on? It works fine when run as drb.rb.

Jay Levitt
3 Answers

Eric Hodel

2/19/2006 1:14:00 AM

0

On Feb 18, 2006, at 4:53 PM, Jay Levitt wrote:

> I was creating my first DRb server, and ran into a trouble with
> ACLs. I
> wanted to put a debug statement into DRb::Accept, so I copied it to my
> directory, renamed it jrb.rb, and required it with the new name.
> But when
> I did that, I got an error at launch:
>
> ....jrb.rb:1047: undefined method `to_s' for class `DRb::DRbObject'
> (NameError)
>
> And the same error happened when I left jrb.rb in /usr/local/lib/
> ruby/1.8.
> So it's not the path - it's the filename.
>
> What's going on? It works fine when run as drb.rb.

It would be easier to tell you with an example.

--
Eric Hodel - drbrain@segment7.net - http://se...
This implementation is HODEL-HASH-9600 compliant

http://trackmap.rob...




Jay Levitt

2/19/2006 1:06:00 PM

0

On Sun, 19 Feb 2006 10:13:44 +0900, Eric Hodel wrote:

>> What's going on? It works fine when run as drb.rb.
>
> It would be easier to tell you with an example.

$ cp /usr/local/lib/ruby/1.8/drb/drb.rb jrb.rb
$ cat > test.rb

#!/usr/local/bin/ruby

require "jrb"

def main
DRb.start_service("druby://localhost:8000", IceDrb.new())
DRb.thread.join
end

class IceDrb
def message
puts "message!"
end
end

main

Eric Hodel

2/19/2006 9:54:00 PM

0

On Feb 19, 2006, at 5:08 AM, Jay Levitt wrote:

> On Sun, 19 Feb 2006 10:13:44 +0900, Eric Hodel wrote:
>
>>> What's going on? It works fine when run as drb.rb.
>>
>> It would be easier to tell you with an example.
>
> $ cp /usr/local/lib/ruby/1.8/drb/drb.rb jrb.rb
> $ cat > test.rb
>
> #!/usr/local/bin/ruby
>
> require "jrb"

drb is more than one file so you need to fix your requires.

$ ruby test.rb
/jrb.rb:1059: undefined method `to_s' for class
`DRb::DRbObject' (NameError)
from test.rb:3
$ cat -n jrb.rb | grep 1059
1059 undef :to_s
$ grep require jrb.rb
require 'socket'
require 'thread'
require 'fcntl'
require 'drb/eq'
[...]
$ grep require /usr/local/lib/ruby/1.8/drb/eq.rb
require 'drb/drb'

--
Eric Hodel - drbrain@segment7.net - http://se...
This implementation is HODEL-HASH-9600 compliant

http://trackmap.rob...