"wrong argument type nil (expected String)" from Dir.chdir

T

Tim Kynerd

I'm running Ruby 1.6.8.

Can anybody tell me why this line:

Dir.chdir("/")

results in the error "wrong argument type nil (expected String)" when
running in the debugger (ruby -r debug), but not when running in irb?

WTF?
 
Y

Yukihiro Matsumoto

Hi,

In message ""wrong argument type nil (expected String)" from Dir.chdir"

|Can anybody tell me why this line:
|
|Dir.chdir("/")
|
|results in the error "wrong argument type nil (expected String)" when
|running in the debugger (ruby -r debug), but not when running in irb?

Can't reproduce. Could you give me more information? Your platform,
and exact version of ruby interpreter (shown by ruby -v).

matz.
 
T

Tim Kynerd

Hi,

In message ""wrong argument type nil (expected String)" from Dir.chdir"

|Can anybody tell me why this line:
|
|Dir.chdir("/")
|
|results in the error "wrong argument type nil (expected String)" when
|running in the debugger (ruby -r debug), but not when running in irb?

Can't reproduce. Could you give me more information? Your platform,
and exact version of ruby interpreter (shown by ruby -v).

matz.

Thanks Matz.

Sorry, should have posted a bit more information to start with. I'm
running under SuSE Linux 8.2, kernel 2.4 (can't find the full version
number). ruby -v reports:

ruby 1.6.8 (2002-12-24) [i686-linux]

After having problems with a similar statement as the first statement in a
program, I tried creating a new program with just the one line I posted
above. That shorter program also returns the "wrong argument type nil
(expected String)" error. However, typing the same line into irb works
fine and returns 0 (and after doing so, typing Dir.getwd into irb returns
the expected "/").

Grateful for any help you can provide.
 
T

Tim Kynerd

Hi,

In message ""wrong argument type nil (expected String)" from Dir.chdir"

|Can anybody tell me why this line:
|
|Dir.chdir("/")
|
|results in the error "wrong argument type nil (expected String)" when
|running in the debugger (ruby -r debug), but not when running in irb?

Can't reproduce. Could you give me more information? Your platform,
and exact version of ruby interpreter (shown by ruby -v).

matz.

Thanks Matz.

Sorry, should have posted a bit more information to start with. I'm
running under SuSE Linux 8.2, kernel 2.4 (can't find the full version
number). ruby -v reports:

ruby 1.6.8 (2002-12-24) [i686-linux]

After having problems with a similar statement as the first statement in
a program, I tried creating a new program with just the one line I
posted above. That shorter program also returns the "wrong argument type
nil (expected String)" error. However, typing the same line into irb
works fine and returns 0 (and after doing so, typing Dir.getwd into irb
returns the expected "/").

Grateful for any help you can provide.

Sorry to be following up to myself, but here's a bit more info (that just
came to me in the shower ;-) ).

The following program:

newdir = "/"
Dir.chdir(newdir)

throws the same error in the debugger, but on the *first* line with the
string assignment. This gives me the strong feeling that something very
non-obvious is going on.

Also, a trip to /usr/src tells me I'm running kernel 2.4.20.
 
R

Robert Klemme

Tim Kynerd said:
Sorry to be following up to myself, but here's a bit more info (that just
came to me in the shower ;-) ).

The following program:

newdir = "/"
Dir.chdir(newdir)

throws the same error in the debugger, but on the *first* line with the
string assignment. This gives me the strong feeling that something very
non-obvious is going on.

Sounds strange indeed.
Also, a trip to /usr/src tells me I'm running kernel 2.4.20.

Is that the same as "uname -a" reports?

robert
 
T

Tim Kynerd

Sounds strange indeed.


Is that the same as "uname -a" reports?

Thanks, couldn't remember how to do that! :)

uname -a reports:

Linux kynerd 2.4.20-4GB #1 Wed Aug 6 18:26:21 UTC 2003 i686 unknown unknown GNU/
Linux
 
T

Tim Kynerd

-snip-


Thanks, couldn't remember how to do that! :)

uname -a reports:

Linux kynerd 2.4.20-4GB #1 Wed Aug 6 18:26:21 UTC 2003 i686 unknown
unknown GNU/ Linux

More data about this problem. Namely: It doesn't appear when I run this
program in Ruby without the debugger, only when I use the debugger.

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

Here I've entered the same lines in irb:

xxx@kynerd:~> irb -v
irb 0.7.4(01/05/08)
xxx@kynerd:~> irb
irb(main):001:0> newdir = "/"
=> "/"
irb(main):002:0> Dir.chdir(newdir)
=> 0
irb(main):003:0> Dir.getwd
=> "/"
irb(main):004:0> exit
xxx@kynerd:~>

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

Here I run a similar program in Ruby without the debugger. I used "cat" to
show the program itself first.

xxx@kynerd:~> cat chdir_test.rb
newdir = "/"
Dir.chdir(newdir)
nowdir = Dir.getwd
puts nowdir
xxx@kynerd:~> ruby chdir_test.rb
/
xxx@kynerd:~>

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

And finally, I run the same program with the debugger:

timk@kynerd:~> ruby -r debug chdir_test.rb Debug.rb
Emacs support available.

chdir_test.rb:1:newdir = "/"
(rdb:1)
nil
(eval):1:wrong argument type nil (expected String)
from chdir_test.rb:1
(rdb:1) q
Really quit? (y/n) y
timk@kynerd:~>

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

It would seem that there is simply something wrong with the debugging
library. I'm thinking of either re-installing or upgrading Ruby to fix
this. Any other ideas?

Again, ruby -v returns:

ruby 1.6.8 (2002-12-24) [i686-linux]
 
T

Tim Kynerd

-snip-


Thanks, couldn't remember how to do that! :)

uname -a reports:

Linux kynerd 2.4.20-4GB #1 Wed Aug 6 18:26:21 UTC 2003 i686 unknown
unknown GNU/ Linux

More data about this problem. Namely: It doesn't appear when I run this
program in Ruby without the debugger, only when I use the debugger.

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

Here I've entered the same lines in irb:

xxx@kynerd:~> irb -v
irb 0.7.4(01/05/08)
xxx@kynerd:~> irb
irb(main):001:0> newdir = "/"
=> "/"
irb(main):002:0> Dir.chdir(newdir)
=> 0
irb(main):003:0> Dir.getwd
=> "/"
irb(main):004:0> exit
xxx@kynerd:~>

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

Here I run a similar program in Ruby without the debugger. I used "cat" to
show the program itself first.

xxx@kynerd:~> cat chdir_test.rb
newdir = "/"
Dir.chdir(newdir)
nowdir = Dir.getwd
puts nowdir
xxx@kynerd:~> ruby chdir_test.rb
/
xxx@kynerd:~>

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

And finally, I run the same program with the debugger:

xxx@kynerd:~> ruby -r debug chdir_test.rb Debug.rb
Emacs support available.

chdir_test.rb:1:newdir = "/"
(rdb:1)
nil
(eval):1:wrong argument type nil (expected String)
from chdir_test.rb:1
(rdb:1) q
Really quit? (y/n) y
xxx@kynerd:~>

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

It would seem that there is simply something wrong with the debugging
library. I'm thinking of either re-installing or upgrading Ruby to fix
this. Any other ideas?

Again, ruby -v returns:

ruby 1.6.8 (2002-12-24) [i686-linux]
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: "wrong argument type nil (expected String)" from Dir.chdir"

|More data about this problem. Namely: It doesn't appear when I run this
|program in Ruby without the debugger, only when I use the debugger.

Might be a bug in debugger. Can you upgrade to ruby-1.8.0 or
1.6-snapshot?

ftp://ftp.ruby-lang.org/pub/ruby/1.6-snapshot.tar.gz

matz.
 
T

Tim Kynerd

Hi,

In message "Re: "wrong argument type nil (expected String)" from Dir.chdir"

|More data about this problem. Namely: It doesn't appear when I run this
|program in Ruby without the debugger, only when I use the debugger.

Might be a bug in debugger. Can you upgrade to ruby-1.8.0 or
1.6-snapshot?

ftp://ftp.ruby-lang.org/pub/ruby/1.6-snapshot.tar.gz

Installed 1.8.0 with the following result:

xxx@kynerd:~> cat chdir_test.rb
Dir.chdir("/")
nowdir = Dir.getwd
puts nowdir
xxx@kynerd:~> irb
irb(main):001:0> Dir.chdir("/")
=> 0
irb(main):002:0> nowdir = Dir.getwd
=> "/"
irb(main):003:0> puts nowdir
/
=> nil
irb(main):004:0> exit
xxx@kynerd:~> ruby chdir_test.rb
/
xxx@kynerd:~> ruby -r debug chdir_test.rb
Debug.rb
Emacs support available.

chdir_test.rb:1:Dir.chdir("/")
(rdb:1)
nil
chdir_test.rb:1:cannot convert nil into String
(rdb:1) q
Really quit? (y/n) y
xxx@kynerd:~> ruby -v
ruby 1.8.0 (2003-08-04) [i686-linux]
xxx@kynerd:~>

I.e.: No luck. :-(
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: "wrong argument type nil (expected String)" from Dir.chdir"

|Installed 1.8.0 with the following result:
|
|xxx@kynerd:~> cat chdir_test.rb
|Dir.chdir("/")
|nowdir = Dir.getwd
|puts nowdir
|xxx@kynerd:~> irb
|irb(main):001:0> Dir.chdir("/")
|=> 0
|irb(main):002:0> nowdir = Dir.getwd
|=> "/"
|irb(main):003:0> puts nowdir
|/
|=> nil
|irb(main):004:0> exit
|xxx@kynerd:~> ruby chdir_test.rb
|/
|xxx@kynerd:~> ruby -r debug chdir_test.rb
|Debug.rb
|Emacs support available.
|
|chdir_test.rb:1:Dir.chdir("/")
|(rdb:1)
|nil
|chdir_test.rb:1:cannot convert nil into String
|(rdb:1) q
|Really quit? (y/n) y
|xxx@kynerd:~> ruby -v
|ruby 1.8.0 (2003-08-04) [i686-linux]
|xxx@kynerd:~>
|
|I.e.: No luck. :-(

Finally, I get it. It's a bug in debug.rb. I fixed it. Thank you.

By the way, it's a lot easier for us to fix, if full step to reproduce
the error was disclosed like this at the first time, without guessing
the (wrong) cause by yourself, folks.

matz.
 
T

Tim Kynerd

Hi,

In message "Re: "wrong argument type nil (expected String)" from Dir.chdir"

|Installed 1.8.0 with the following result:
|
|xxx@kynerd:~> cat chdir_test.rb
|Dir.chdir("/")
|nowdir = Dir.getwd
|puts nowdir
|xxx@kynerd:~> irb
|irb(main):001:0> Dir.chdir("/")
|=> 0
|irb(main):002:0> nowdir = Dir.getwd
|=> "/"
|irb(main):003:0> puts nowdir
|/
|=> nil
|irb(main):004:0> exit
|xxx@kynerd:~> ruby chdir_test.rb
|/
|xxx@kynerd:~> ruby -r debug chdir_test.rb
|Debug.rb
|Emacs support available.
|
|chdir_test.rb:1:Dir.chdir("/")
|(rdb:1)
|nil
|chdir_test.rb:1:cannot convert nil into String
|(rdb:1) q
|Really quit? (y/n) y
|xxx@kynerd:~> ruby -v
|ruby 1.8.0 (2003-08-04) [i686-linux]
|xxx@kynerd:~>
|
|I.e.: No luck. :-(

Finally, I get it. It's a bug in debug.rb. I fixed it. Thank you.

No, thank YOU.
By the way, it's a lot easier for us to fix, if full step to reproduce
the error was disclosed like this at the first time, without guessing
the (wrong) cause by yourself, folks.

That I'm not sure what to do with. I don't see that it applies at all to
my initial post.
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: "wrong argument type nil (expected String)" from Dir.chdir"

|> By the way, it's a lot easier for us to fix, if full step to reproduce
|> the error was disclosed like this at the first time, without guessing
|> the (wrong) cause by yourself, folks.
|
|That I'm not sure what to do with. I don't see that it applies at all to
|my initial post.

The problem has nothing related to Dir.chdir. Please give us
something like the steps quoted below at the first time, it would help
us a lot.

matz.

|> |Installed 1.8.0 with the following result:
|> |
|> |xxx@kynerd:~> cat chdir_test.rb
|> |Dir.chdir("/")
|> |nowdir = Dir.getwd
|> |puts nowdir
|> |xxx@kynerd:~> irb
|> |irb(main):001:0> Dir.chdir("/")
|> |=> 0
|> |irb(main):002:0> nowdir = Dir.getwd
|> |=> "/"
|> |irb(main):003:0> puts nowdir
|> |/
|> |=> nil
|> |irb(main):004:0> exit
|> |xxx@kynerd:~> ruby chdir_test.rb
|> |/
|> |xxx@kynerd:~> ruby -r debug chdir_test.rb
|> |Debug.rb
|> |Emacs support available.
|> |
|> |chdir_test.rb:1:Dir.chdir("/")
|> |(rdb:1)
|> |nil
|> |chdir_test.rb:1:cannot convert nil into String
|> |(rdb:1) q
|> |Really quit? (y/n) y
|> |xxx@kynerd:~> ruby -v
|> |ruby 1.8.0 (2003-08-04) [i686-linux]
|> |xxx@kynerd:~>
|> |
|> |I.e.: No luck. :-(
 

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,767
Messages
2,569,573
Members
45,046
Latest member
Gavizuho

Latest Threads

Top