4

我正在尝试使用 net/sftp gem 从 Heroku 的 SFTP To Go 下载文件,但我总是得到未定义的方法 `e=' for #.

一直在网上搜索,但找不到任何相关的解决方案。这是我的代码:

task employer_email_import: :environment do
  require 'net/sftp'
  require 'uri'

  sftptogo_url = ENV['SFTPTOGO_URL']
  uri = URI.parse(sftptogo_url)

  Net::SFTP.start(uri.host, uri.user, :password => uri.password) do |sftp|
     sftp.download!("some_directory", "some_directory")
  end

end

错误: #< OpenSSL::PKey::RSA:0x00563aaff72138> 的未定义方法 `e=' 您的意思是?e**********

“/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/buffer.rb:255:in read_keyblob'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/buffer.rb:239:inread_key' ", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb:145:in block (2 levels) in keys_for'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb:127:ineach_line'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb:127 :in block in keys_for'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb:125:inopen'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb :125:in keys_for'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb:55:inblock in search_in'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh /known_hosts.rb:55:in map'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb:55:insearch_in'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net /ssh/known_hosts.rb:49:insearch_for'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/session.rb:96:inhost_keys'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/algorithms.rb :251:in prepare_preferred_algorithms!'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/algorithms.rb:124:ininitialize'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/transport /session.rb:86:in new'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/session.rb:86:ininitialize'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net /ssh.rb:232:in new'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh.rb:232:instart'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-sftp-2.1.2/lib/net /sftp.rb:31:in start'", "/home/romz/Desktop/Romz/site/ROR/recoverysuite/lib/tasks/scheduler.rake:376:inblock (2 levels) in '", "/home/romz/Desktop/Romz/site/ROR/recoverysuite/lib/tasks/scheduler.rake:353:in each'", "/home/romz/Desktop/Romz/site/ROR/recoverysuite/lib/tasks/scheduler.rake:353:inblock in '", " /home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/task.rb:248:inblock in execute'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/task.rb:243:in每个'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/task.rb:243:inexecute'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/task.rb:187:in块invoke_with_call_chain'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:214:in mon_synchronize'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/task.rb:180:ininvoke_with_call_chain'", "/home/romz/.rbenv/versions/2.4 .0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/task.rb:173:in invoke'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:152:ininvoke_task'", "/home/romz/.rbenv/versions/2.4.0 /lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:108:in block (2 levels) in top_level'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:108:ineach'", "/home/romz/.rbenv/versions/2.4.0/lib /ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:108:in block in top_level'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:117:inrun_with_threads'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby /gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:102:intop_level'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:80:in阻止运行'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:178:instandard_exception_handling'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:77:in运行'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/exe/rake:27:in <top (required)>'", "/home/romz/.rbenv/versions/2.4.0/bin/rake:23:inload'", "/ home/romz/.rbenv/versions/2.4.0/bin/rake:23:in <top (required)>'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/cli/exec.rb:74:inload'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems /bundler-2.0.1/lib/bundler/cli/exec.rb:74:in kernel_load'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/cli/exec.rb:28:inrun'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems /bundler-2.0.1/lib/bundler/cli.rb:463:in exec'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:inrun'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler -2.0.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in invoke_command'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor.rb:387:indispatch'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4 .0/gems/bundler-2.0.1/lib/bundler/cli.rb:27:indispatch'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in开始'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/cli.rb:18:instart'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/exe/bundle:30:in块'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/friendly_errors.rb:124:in with_friendly_errors'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/exe/bundle:22:in'", “/home/romz/.rbenv/versions/2.4.0/bin/bundle:23:in load'", "/home/romz/.rbenv/versions/2.4.0/bin/bundle:23:in'”


RUBY_VERSION => "2.4.0"

OpenSSL::OPENSSL_VERSION => "OpenSSL 1.1.0g 2017 年 11 月 2 日"

OpenSSL::VERSION => "2.0.2"

rails --version => Rails 5.0.7.1

4

1 回答 1

4

利用:

gem 'net-sftp'

gem 'net-ssh', '~> 5.1.0'

gem 'openssl', '~> 2.0.0.beta.1'

这将解决您的问题。

于 2019-11-22T07:35:56.447 回答