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

Already on GitHub? Sign in to your account

Example code fails with httpclient/auth.rb:564:in `get': undefined method `init_context' for nil:NilClass (NoMethodError) #34

pkolmann opened this Issue Dec 27, 2012 · 4 comments


None yet
4 participants


I am new to ruby and WinRM on linux but I would like to use it. I installed the required gems on a Debian unstable box and now I am trying to run the example script against a test environment:


require 'winrm'
endpoint = 'http://dc01.DOMAIN.tuwien.ac.at:5985/wsman'
winrm = WinRM::WinRMWebService.new(endpoint, :plaintext, :user => 'DOMAIN\Administrator', :pass => 'PASSWORD')
winrm.cmd('ipconfig /all') do |stdout, stderr|
STDOUT.print stdout
STDERR.print stderr

On the windows box I see winrshost.exe and conhost.exe beeing spawned but on linux I get the following output:

/var/lib/gems/1.9.1/gems/httpclient- get': undefined methodinit_context' for nil:NilClass (NoMethodError)
from /var/lib/gems/1.9.1/gems/httpclient- block in filter_request' from /var/lib/gems/1.9.1/gems/httpclient-'
from /var/lib/gems/1.9.1/gems/httpclient- filter_request' from /var/lib/gems/1.9.1/gems/httpclient- in do_get_block'
from /var/lib/gems/1.9.1/gems/httpclient- each' from /var/lib/gems/1.9.1/gems/httpclient-'
from /var/lib/gems/1.9.1/gems/httpclient- block in do_request' from /var/lib/gems/1.9.1/gems/httpclient-'
from /var/lib/gems/1.9.1/gems/httpclient- do_request' from /var/lib/gems/1.9.1/gems/httpclient-'
from /var/lib/gems/1.9.1/gems/httpclient- post' from /var/lib/gems/1.9.1/gems/winrm-1.1.2/lib/winrm/http/transport.rb:38:insend_request'
from /var/lib/gems/1.9.1/gems/winrm-1.1.2/lib/winrm/winrm_service.rb:368:in send_message' from /var/lib/gems/1.9.1/gems/winrm-1.1.2/lib/winrm/winrm_service.rb:136:inrun_command'
from /var/lib/gems/1.9.1/gems/winrm-1.1.2/lib/winrm/winrm_service.rb:240:in run_cmd' from ./ex1.rb:9:in


Do you have any idea, what I have done wrong?
I have enabled UnecryptedTransport and Basic Auth.


jdub commented Mar 8, 2013

Getting the same thing. Ubuntu, Ruby 1.9.3-p125, winrm dependencies built and installed, very much the same test script and configuration vs. Windows 2012 Core.

I'm being bitten by this error as well. Using an OS X machine to talk to a Windows 2008 R2 machine. Haven't been able to figure out how to fix or work around it yet. @zenchild any suggestions?

edit: I added the :basic_auth_only => true option to my instance of WinRM::WinRMWebService and it worked. @jdub and @pkolmann


pmorton commented Mar 22, 2013

I was just searching for this fix :basic_auth_only => true. What this does is turn off GSSAPI authentication in the HTTP client. What is happening is that the httpclient sees that GSSAPI gem is installed and tries to use it. If you are on a machine that does not have a full kerberos environment (or one at all), httpclient still tries to use kerberos even though your environment is not complete.

I am working on a major update to the WinRM gem and some of the underlying libraries. In specific, I am in the process of fixing up the rubyntlm gem so that authentication works seamlessly out of the box with the winrm gem.


pmorton commented Mar 22, 2013

You can also specify :disable_sspi => true to turn off kerberos only. Please re-open this bug either of these do not resolve your issue.

@pmorton pmorton closed this Mar 22, 2013

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