Forum: Ruby net/sftp 1.10 errors

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F0223b1193ecc3a935ce41a1edd72e42?d=identicon&s=25 zdennis (Guest)
on 2006-02-14 15:13
(Received via mailing list)
I recently downloaded net/ssh 1.0.7 and net/sftp 1.1.0. But I get
problems with ruby 1.8.2, 1.8.3 on
either windows, debian or ubuntu boxes.

require 'rubygems'
require 'net/sftp'

sftp_sess = Net::SFTP.start 'host', 'username', 'password'
sftp_sess.put_file '/home/uberriffic/test.txt',
'/home/uberriffic/remote_test.txt'
NoMethodError: private method `open' called for
#<Net::SFTP::Protocol::Driver:0xb7863790>
         from
/usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/protocol/driver.rb:201:in
`method_missing'
         from
/usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/operations/open.rb:27:in
`perform'
         from
/usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/operations/abstract.rb:64:in
`execute'
         from
/usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:253:in
`method_missing'
         from
/usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:177:in
`open_handle'
         from
/usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:203:in
`put_file'
         from (irb):4
         from :0

Do I need ruby 1.8.4? Thanks

Zach
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-02-14 16:34
(Received via mailing list)
On Feb 14, 2006, at 6:03 AM, zdennis wrote:

> NoMethodError: private method `open' called for
> sftp/session.rb:177:in `open_handle'
>         from /usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/
> sftp/session.rb:203:in `put_file'
>         from (irb):4
>         from :0
>
> Do I need ruby 1.8.4? Thanks
>
> Zach

Zach,

Thanks for this report. I'm not sure yet what's going wrong here, but
I can duplicate the error on my machine and I'll look into it.

- Jamis
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-02-14 16:38
(Received via mailing list)
On Feb 14, 2006, at 6:03 AM, zdennis wrote:

> NoMethodError: private method `open' called for
> sftp/session.rb:177:in `open_handle'
>         from /usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/
> sftp/session.rb:203:in `put_file'
>         from (irb):4
>         from :0

Here are two workarounds:

First, you can use a block to Net::SFTP.start:

   Net::SFTP.start(...) do |sess|
     sess.put_file(...)
   end

Or, if you can't use the block format for whatever reason, be sure to
call #connect after calling start:

   sess = Net::SFTP.start(...)
   sess.connect
   sess.put_file(...)

Not sure why that connect isn't being called automatically, but I'll
look into it.

- Jamis
Ff43001ac5fe9805aa6ca2e89d3b7b5d?d=identicon&s=25 Jake Janovetz (janovetz)
on 2006-02-15 02:12
Jamis Buck wrote:
>
> Not sure why that connect isn't being called automatically, but I'll
> look into it.
>
> - Jamis

A bit off topic for this thread, but is Net::SFTP the best way to do
things like user-uploads to a rails app to a remote host like
Strongspace?

   Jake
F0223b1193ecc3a935ce41a1edd72e42?d=identicon&s=25 zdennis (Guest)
on 2006-02-15 03:34
(Received via mailing list)
Jamis Buck wrote:
>> sftp_sess.put_file '/home/uberriffic/test.txt', '/home/uberriffic/
>> sftp/session.rb:253:in `method_missing'
> First, you can use a block to Net::SFTP.start:
>   sess.put_file(...)
>
> Not sure why that connect isn't being called automatically, but I'll
> look into it.
>

Thank you very much Jamis!

Zach
This topic is locked and can not be replied to.