Problems getting directory listings #5

bitboxer opened this Issue Mar 12, 2011 · 7 comments


None yet

2 participants


I have a small problem connecting to one of our servers. I have this little test code:

require 'net/sftp'

Net::SFTP.start('SERVER', 'USER', {:password => 'PASSWORT'}) do |sftp| 
  puts "connected"

  sftp.dir.foreach(".") do |entry|
    puts entry.longname

I get this exception:

net-ssh-2.1.3/lib/net/ssh/buffer.rb:294:in `pack': can't convert nil into Integer (TypeError)
from /path/net-ssh-2.1.3/lib/net/ssh/buffer.rb:294:in `write_long'
from /path/net-sftp-2.0.5/lib/net/sftp/protocol/04/attributes.rb:144:in `block in encode_acl'
from /path/net-sftp-2.0.5/lib/net/sftp/protocol/04/attributes.rb:143:in `each'
from /path/net-sftp-2.0.5/lib/net/sftp/protocol/04/attributes.rb:143:in `encode_acl'
from /path/net-sftp-2.0.5/lib/net/sftp/protocol/01/attributes.rb:286:in `block in to_s'
from /path/net-sftp-2.0.5/lib/net/sftp/protocol/01/attributes.rb:283:in `each'
from /path/net-sftp-2.0.5/lib/net/sftp/protocol/01/attributes.rb:283:in `to_s'
from /path/net-sftp-2.0.5/lib/net/sftp/protocol/04/name.rb:59:in `inspect'
from /path/net-sftp-2.0.5/lib/net/sftp/protocol/04/name.rb:59:in `longname'
from test.rb:7:in `block (2 levels) in <main>'
from /path/net-sftp-2.0.5/lib/net/sftp/operations/dir.rb:33:in `block in foreach'
from /path/net-sftp-2.0.5/lib/net/sftp/operations/dir.rb:33:in `each'
from /path/net-sftp-2.0.5/lib/net/sftp/operations/dir.rb:33:in `foreach'
from test.rb:6:in `block in <main>'
from /path/net-sftp-2.0.5/lib/net/sftp/session.rb:939:in `call'
from /path/net-sftp-2.0.5/lib/net/sftp/session.rb:939:in `block in do_version'
from /path/net-sftp-2.0.5/lib/net/sftp/session.rb:939:in `each'
from /path/net-sftp-2.0.5/lib/net/sftp/session.rb:939:in `do_version'
from /path/net-sftp-2.0.5/lib/net/sftp/session.rb:909:in `when_channel_polled'
from /path/net-ssh-2.1.3/lib/net/ssh/connection/channel.rb:311:in `call'
from /path/net-ssh-2.1.3/lib/net/ssh/connection/channel.rb:311:in `process'
from /path/net-ssh-2.1.3/lib/net/ssh/connection/session.rb:214:in `block in preprocess'
from /path/net-ssh-2.1.3/lib/net/ssh/connection/session.rb:214:in `each'
from /path/net-ssh-2.1.3/lib/net/ssh/connection/session.rb:214:in `preprocess'
from /path/net-ssh-2.1.3/lib/net/ssh/connection/session.rb:197:in `process'
from /path/net-ssh-2.1.3/lib/net/ssh/connection/session.rb:161:in `block in loop'
from /path/net-ssh-2.1.3/lib/net/ssh/connection/session.rb:161:in `loop'
from /path/net-ssh-2.1.3/lib/net/ssh/connection/session.rb:161:in `loop'
from /path/net-sftp-2.0.5/lib/net/sftp/session.rb:802:in `loop'
from /path/net-sftp-2.0.5/lib/net/sftp/session.rb:787:in `connect!'
from /path/net-sftp-2.0.5/lib/net/sftp.rb:32:in `start'
from test.rb:3:in `<main>'

I have added a

 puts attributes.inspect

into the name.rb to check it's contents and it was this:


can this mean that there was an encoding issue and the code couldn't parse the answer from the server?

When using a sftp command line utility or java, I can connect without any problem. The server seems to be working perfectly.

delano commented Mar 12, 2011

Thanks for the report. What OS/Ruby version?


I am using Mac Os 10.6.6 and Ruby 1.9.2p180 .


Sadly I can't give you access to the server, but If you need help identifying the problem, I am happy to assist you.

delano commented Mar 14, 2011

Thanks for the update. I'll try to take a look this week.


I am still having this problem :( . I really want to help you to pinpoint the problem. If there is anything you need, feel free to contact me

bitboxer commented Apr 2, 2011

No, sorry. I can't give you access to that machine. It's a production server. But I can offer you a wireshark dump or whatever you need

delano commented Apr 11, 2011

I took a look but I couldn't replicate it and didn't see any obvious problems in the code.

Unfortunately that's all I can do for now, but I'm happy to pull in a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment