Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `chomp' for nil:NilClass #437

Closed
ahwanghwa opened this issue Oct 13, 2016 · 3 comments
Closed

undefined method `chomp' for nil:NilClass #437

ahwanghwa opened this issue Oct 13, 2016 · 3 comments

Comments

@ahwanghwa
Copy link

Hello everyone,

We use net-ssh 3.1.1 and ruby 2.1.5.
We run ruby rake task as a scheduled job every other hour and sometimes get the following error:

22:31:25 NoMethodError: undefined method `chomp' for nil:NilClass
22:31:25 /apps/amex-data-processor/shared/bundle/ruby/2.1.0/gems/net-ssh-3.1.1/lib/net/ssh/prompt.rb:73:in 'prompt'
22:31:25 /apps/amex-data-processor/shared/bundle/ruby/2.1.0/gems/net-ssh-3.1.1/lib/net/ssh/authentication/methods/password.rb:57:in 'ask_password'
22:31:25 /apps/amex-data-processor/shared/bundle/ruby/2.1.0/gems/net-ssh-3.1.1/lib/net/ssh/authentication/methods/password.rb:22:in 'authenticate'
22:31:25 /apps/amex-data-processor/shared/bundle/ruby/2.1.0/gems/net-ssh-3.1.1/lib/net/ssh/authentication/session.rb:79:in 'block in authenticate'
22:31:25 /apps/amex-data-processor/shared/bundle/ruby/2.1.0/gems/net-ssh-3.1.1/lib/net/ssh/authentication/session.rb:66:in 'each'
22:31:25 /apps/amex-data-processor/shared/bundle/ruby/2.1.0/gems/net-ssh-3.1.1/lib/net/ssh/authentication/session.rb:66:in 'authenticate'
22:31:25 /apps/amex-data-processor/shared/bundle/ruby/2.1.0/gems/net-ssh-3.1.1/lib/net/ssh.rb:233:in 'start'
22:31:25 /apps/amex-data-processor/shared/bundle/ruby/2.1.0/gems/net-sftp-2.1.2/lib/net/sftp.rb:31:in 'start'
22:31:25 /apps/amex-data-processor/releases/20160824215913/lib/amex_data_processing.rb:7:in 'run'
22:31:25 /apps/amex-data-processor/releases/20160824215913/lib/tasks/amex_disputes.rake:5:in 'block (2 levels) in <top (required)>'

Our code looks like the following:

Net::SFTP.start(AMEX_SFTP_CONFIG[:host], AMEX_SFTP_CONFIG[:user], password: AMEX_SFTP_CONFIG[:password]) do |sftp|
      sftp.dir.foreach(AMEX_SFTP_CONFIG[:directory]) do |entry|
        next unless entry.longname =~ /CBNOT#/
        sftp_file_names << entry.name
      end

      file_names = sftp_file_names - processed_file_names

      file_names.each { |name| sftp.download!("#{AMEX_SFTP_CONFIG[:directory]}/#{name}", "/tmp/#{name}") }
end

The issue seems to be very similar to: #234, #424
Could you please help with the issue?

@mfazekas
Copy link
Collaborator

This indicates that the password was not accepted an it tried to prompt but there seems to be no $stdin. Since this is a non interactive usecase please pass non_interactive: true

@baelter
Copy link

baelter commented Nov 22, 2016

ok @mfazekas, but maybe you should catch and re raise?

@mfazekas
Copy link
Collaborator

@baelter yes, right. feel free to submit a patch that checks if $stdin is nil and raises a more descriptive error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants