Sinatra error - continuation called across threads - ruby

I am completely new to Ruby so my question may have quite a simple answer. However, I couldn't find an answer on stackoverflow.
I have the following very simple Sinatra app:
# myapp.rb
require 'rubygems'
require 'sinatra'
require 'json'
range=(199..2000).step(1)
set :port, 8888
get '/hostname' do
content_type :json
return range.next.to_json
end
Sinatra is starting:
ruby testsinatra.rb
== Sinatra/1.0 has taken the stage on 8888 for development with backup from WEBrick
[2014-09-11 08:43:18] INFO WEBrick 1.3.1
[2014-09-11 08:43:18] INFO ruby 1.8.7 (2011-06-30) [x86_64-linux]
[2014-09-11 08:43:18] INFO WEBrick::HTTPServer#start: pid=8215 port=8888
and serving first request:
curl -ks http://localhost:8888/hostname
199
but failing with an error at the second request:
RuntimeError - continuation called across threads:
/usr/lib/ruby/1.8/generator.rb:131:in `call'
/usr/lib/ruby/1.8/generator.rb:131:in `next'
/usr/lib/ruby/1.8/generator.rb:189:in `next'
testsinatra.rb:30:in `GET /hostname'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:863:in `call'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:863:in `route'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `instance_eval'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `route_eval'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:500:in `route!'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:497:in `catch'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:497:in `route!'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:476:in `each'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:476:in `route!'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:601:in `dispatch!'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:411:in `call!'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `instance_eval'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `invoke'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `catch'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `invoke'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:411:in `call!'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:399:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.5.2/lib/rack/showexceptions.rb:24:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.5.2/lib/rack/commonlogger.rb:33:in `call'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:979:in `call'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:1003:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:1003:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:979:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/gems/1.8/gems/rack-1.5.2/lib/rack/handler/webrick.rb:14:in `run'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:946:in `run!'
/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/main.rb:25
testsinatra.rb:27
Clearly, I'm missing something basic. Please advice.

Testing the code gives:
FiberError at /hostname
fiber called across threads
You can find a related question here: Sharing an enumerator across threads . It seems that the Fiber code stores the ID of the first thread that made an access to the object, and immediately fails when another thread tries to do so. You apparently just can't share enumerators between threads, and must resort to different means.
Please also note that global variables might be accessed simultaneously by different threads and you should always use thread-safe objects or explicit locking.

Related

Openshift rhc port forward exception

I am trying to open ports so i access my database remotely from my pc
I am running on Ruby200-x64 and when i try to access port forward
rhc port-forward -a appname
i get the following response/error:
Checking available ports ... C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:176:in `malloc': bignum too big to convert into `long' (RangeError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:176:in `malloc_ptr'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:240:in `get_token_information'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:213:in `get_current_user'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:189:in `get_security_attributes_for_user'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:332:in `send_query'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:309:in `send'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/agent/socket.rb:148:in `send_packet'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/agent/socket.rb:165:in `send_and_wait'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/agent/socket.rb:76:in `negotiate!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/agent/socket.rb:48:in `connect'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/key_manager.rb:179:in `agent'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/key_manager.rb:103:in `each_identity'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/methods/publickey.rb:19:in `authenticate'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:79:in `block in authenticate'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:66:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:66:in `authenticate'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh.rb:211:in `start'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rhc-1.38.4/lib/rhc/commands/port_forward.rb:86:in `run'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rhc-1.38.4/lib/rhc/commands.rb:294:in `execute'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rhc-1.38.4/lib/rhc/commands.rb:285:in `block (3 levels) in to_commander'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/commander-4.2.1/lib/commander/command.rb:180:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/commander-4.2.1/lib/commander/command.rb:180:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/commander-4.2.1/lib/commander/command.rb:155:in `run'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/commander-4.2.1/lib/commander/runner.rb:421:in `run_active_command'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rhc-1.38.4/lib/rhc/command_runner.rb:72:in `run!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/commander-4.2.1/lib/commander/delegates.rb:8:in `run!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rhc-1.38.4/lib/rhc/cli.rb:37:in `start'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rhc-1.38.4/bin/rhc:20:in `<top (required)>'
from C:/Ruby200-x64/bin/rhc:23:in `load'
from C:/Ruby200-x64/bin/rhc:23:in `<main>'
It's a bit late but maybe it can help to newcomer.
The solution is, or better say- workaround, to exit the pageant while you port-forward the app. And when done turn it on again if you need to ssh to it.
I found a sort of workaround too, whenever i recieve this error i do the oldest trick in the books, a restart and it works all the times(for now)

Download multiple XML files

I'm writing an application to parse XML. I have to obtain data from one XML file, and then in a loop I have to open another XML file.
The code looks like this:
$doc = Nokogiri::XML(open('myxmladress'))
$doc.xpath('//job').each do |job|
if job.xpath('name').text.include?('joe')
$doc2 = Nokogiri::XML(open('myxmladress_for_joe'))
end
end
I believe that I cannot have multiple HTTP connections open.
Can I simply download the whole file instead of using
$doc Nokogiri::XML(open('myxmladress'))
or is there any way to close the Nokogiri HTTP connection?
What is more I'm downloading it by https.
My error:
in `open_http': 500 Server Error (OpenURI::HTTPError)
from /home/nagios/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/open-uri.rb:737:in `buffer_open'
from /home/nagios/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/open-uri.rb:212:in `block in open_loop'
from /home/nagios/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/open-uri.rb:210:in `catch'
from /home/nagios/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/open-uri.rb:210:in `open_loop'
from /home/nagios/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/open-uri.rb:151:in `open_uri'
from /home/nagios/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/open-uri.rb:717:in `open'
from /home/nagios/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/open-uri.rb:35:in `open'
from jenkins_auth.rb:97:in `block (2 levels) in combine_partial_results'
from /home/nagios/.rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:187:in `block in each'
from /home/nagios/.rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:186:in `upto'
from /home/nagios/.rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:186:in `each'
from jenkins_auth.rb:89:in `block in combine_partial_results'
from /home/nagios/.rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:187:in `block in each'
from /home/nagios/.rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:186:in `upto'
from /home/nagios/.rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:186:in `each'
from jenkins_auth.rb:86:in `combine_partial_results'
from jenkins_auth.rb:130:in `get_tests_for_job'
from jenkins_auth.rb:137:in `<main>'
You are using OpenUri to fetch a document from a URL. I am pretty sure that this doesn't leave any open connection, but reads the document into an IO like object, kind of like a file.
Your problem seems to be that the server has had an internal error.

Ruby/Cucumber - 'puts' causing trouble

We have recently installed a copy of our framework on another machine, and for some reason we get an error when using 'puts' instead of 'Kernel.puts' (we use Ruby)
This isn't a huge issue, but we occasionally use 'puts' to write to the cucumber results file.
This onlyhappens on 1 machine, not the other. Both are mac minis, same specs.
Both machines have the same gemlist, the same version of Ruby etc (they were both installed almost simultaneously).
Anyone else seen this?
Log:
2015-06-30 14:44:59 +0100 OUT: Error: undefined method <<' for nil:NilClass 2015-06-30 14:44:59 +0100 OUT: /Library/Ruby/Gems/2.0.0/gems/gherkin-2.12.2/lib/gherkin/formatter/json_formatter.rb:89:inwrite'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/formatter/gherkin_formatter_adapter.rb:166:in puts' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:181:inblock in send_to_all'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:179:in each' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:179:insend_to_all'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:173:in broadcast' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:154:inputs'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/user_interface.rb:14:in puts' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/rb_support/rb_world.rb:107:inputs'
/Users/jenkins/workspace/TEST-regression-test_trial_mini/automation/ios/features/support/hooks.rb:104:in block in <top (required)>' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/core_ext/instance_exec.rb:48:ininstance_exec'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/core_ext/instance_exec.rb:48:in block in cucumber_instance_exec' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/core_ext/instance_exec.rb:69:incucumber_run_with_backtrace_filtering'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/core_ext/instance_exec.rb:36:in cucumber_instance_exec' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/rb_support/rb_hook.rb:14:ininvoke'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/language_support/language_methods.rb:114:in invoke' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/language_support/language_methods.rb:102:inblock in execute_before'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/language_support/language_methods.rb:101:in each' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/language_support/language_methods.rb:101:inexecute_before'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/language_support/language_methods.rb:15:in before' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/support_code.rb:112:inblock in fire_hook'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/support_code.rb:111:in each' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/support_code.rb:111:infire_hook'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime.rb:107:in before' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime.rb:98:inbefore_and_after'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime.rb:82:in block in with_hooks' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/support_code.rb:120:incall'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/support_code.rb:120:in block (3 levels) in around' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/language_support/language_methods.rb:9:inblock in around'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/language_support/language_methods.rb:97:in call' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/language_support/language_methods.rb:97:inexecute_around'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/language_support/language_methods.rb:8:in around' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/support_code.rb:119:inblock (2 levels) in around'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/support_code.rb:123:in call' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/support_code.rb:123:inaround'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime.rb:94:in around' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime.rb:81:inwith_hooks'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:13:in execute' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/scenario.rb:32:inblock in accept'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/scenario.rb:79:in with_visitor' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/scenario.rb:31:inaccept'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:58:in block in visit_feature_element' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:170:inbroadcast'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:57:in visit_feature_element' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/feature.rb:38:inblock in accept'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/feature.rb:37:in each' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/feature.rb:37:inaccept'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:27:in block in visit_feature' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:170:inbroadcast'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:26:in visit_feature' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/features.rb:28:inblock in accept'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/features.rb:17:in each' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/features.rb:17:ineach'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/features.rb:27:in accept' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:21:inblock in visit_features'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:170:in broadcast' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/ast/tree_walker.rb:20:invisit_features'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime.rb:49:in run!' /Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/cli/main.rb:47:inexecute!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/bin/cucumber:13:in <top (required)>' /usr/bin/cucumber:23:inload'
/usr/bin/cucumber:23:in
Something somewhere is overriding your puts. You'll just have to find it. As an alternative, use warn. From Avdi Grimm's Exceptional Ruby:
puts leaves something to be desired as a failure reporting method, however. Because its output goes to $stdout, which is buffered by default, output may not be printed immediately, or it may come out in a surprising order
warn is more succinct, while still using $stderr as its output stream. Note also that the output of warn can be temporarily silenced by passing the -W0 flag to Ruby.

Ruby, Net-SSH: connection closed by remote host

Issue where SSH session gets disconnected after less than 1 sec by remote when using ruby net-ssh. It happens very randomly.
/home/admin/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.2/lib/net/ssh/transport/packet_stream.rb:89:in `next_packet': connection closed by remote host (Net::SSH::Disconnect)
from /home/admin/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:183:in `block in poll_message'
from /home/admin/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:178:in `loop'
from /home/admin/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:178:in `poll_message'
from /home/admin/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.2/lib/net/ssh/connection/session.rb:461:in `dispatch_incoming_packets'
from /home/admin/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.2/lib/net/ssh/connection/session.rb:222:in `preprocess'
from /home/admin/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.2/lib/net/ssh/connection/session.rb:206:in `process'
from /home/admin/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.2/lib/net/ssh/connection/session.rb:170:in `block in loop'
from /home/admin/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.2/lib/net/ssh/connection/session.rb:170:in `loop'
from /home/admin/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.2/lib/net/ssh/connection/session.rb:170:in `loop'
from /home/user/ruby/cisco/ssh.rb:43:in `run'
from /home/user/ruby/cisco/base.rb:48:in `run'
from rssh.rb:11:in `<main>'
Already tried specifying timeout settings and encryption algorithms.
Solution at https://github.com/net-ssh/net-ssh/issues/93 does not fix the issue

chef-shell --solo Chef::Exceptions::PrivateKeyMissing

I am building a recipe where I'm trying to debug how the attributes are being set, but when I execute chef-shell it gives me errors about missing /etc/chef/client.pem, from what I can tell those are generated by chef server, as I'm running in --solo mode shouldn't it skip the requirement for such things? Or am I using chef-shell improperly?
chef-shell --solo -c debug/solo.rb -j debug/nodes.json
loading configuration: debug/solo.rb
Session type: solo
Loading...done.
This is the chef-shell.
Chef Version: 11.14.6
http://www.opscode.com/chef
http://docs.opscode.com/
run `help' for help, `exit' or ^D to quit.
Ohai2u bob#MSIGS70stealth.thalhalla.net!
chef > roles.all
[2014-11-10T13:15:08-06:00] WARN: Failed to read the private key /etc/chef/client.pem: #<Errno::ENOENT: No such file or directory # rb_sysopen - /etc/chef/client.pem>
Chef::Exceptions::PrivateKeyMissing: I cannot read /etc/chef/client.pem, which you told me to use to sign requests!
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/http/authenticator.rb:78:in `rescue in load_signing_key'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/http/authenticator.rb:68:in `load_signing_key'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/http/authenticator.rb:38:in `initialize'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/rest.rb:66:in `new'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/rest.rb:66:in `initialize'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/search/query.rb:34:in `new'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/search/query.rb:34:in `initialize'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/role.rb:184:in `new'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/role.rb:184:in `list'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/shell/model_wrapper.rb:82:in `list_objects'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/shell/model_wrapper.rb:50:in `all'
from (irb):1
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/shell.rb:75:in `block in start'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/shell.rb:74:in `catch'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/shell.rb:74:in `start'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/bin/chef-shell:37:in `<top (required)>'
from /home/bob/.rvm/gems/ruby-2.1.0/bin/chef-shell:23:in `load'
from /home/bob/.rvm/gems/ruby-2.1.0/bin/chef-shell:23:in `<main>'
from /home/bob/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks2.1:15:in `eval'
from /home/bob/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks2.1:15:in `<main>'chef >
That method just isn't supported in solo mode. You can see in the code that is just calls either search or chef_server_rest directly.

Resources