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 'sh' for VagrantPlugins CommunicatorWinRM #90

Open
chriskilding opened this issue Jul 25, 2014 · 6 comments
Open

Undefined method 'sh' for VagrantPlugins CommunicatorWinRM #90

chriskilding opened this issue Jul 25, 2014 · 6 comments

Comments

@chriskilding
Copy link

This issue has been migrated from (#4249)[https://github.com/hashicorp/vagrant/issues/4249] in Vagrant core, after @sneal found it to be a bug with this plugin instead.


I got the following error when trying to provision a Windows Server 2008 R2 box with Chef Solo and vagrant-omnibus. A cursory look suggests something thought it was in *nix land and called 'sh' when it shouldn't have done.

The box I'm using is https://vagrantcloud.com/ferventcoder/win2008r2-x64-nocm. Running on Vagrant 1.6.3 / OSX 10.9 / latest Chef development kit with integrated Berkshelf.

==> windows: Mounting shared folders...
    windows: /vagrant => /Users/[me]/Documents/Git/rtsproto_backend
    windows: /tmp/vagrant-chef-2/chef-solo-1/cookbooks => /Users/[me]/.berkshelf/windows/vagrant/berkshelf-20140725-1855-1muei20-windows
==> windows: Forcing shutdown of VM...
==> windows: Destroying VM and associated drives...
==> windows: Running cleanup tasks for 'chef_solo' provisioner...
/Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/plugins/communicators/winrm/communicator.rb:76:in `execute': undefined method `sh' for #<VagrantPlugins::CommunicatorWinRM::WinRMShell:0x000001009dab10> (NoMethodError)
    from /Users/[me]/.vagrant.d/gems/gems/vagrant-omnibus-1.4.1/lib/vagrant-omnibus/action/install_chef.rb:144:in `installed_version'
...
@ryancragun
Copy link

I'm seeing the same thing here:

/Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/plugins/communicators/winrm/communicator.rb:76:in `execute': undefined method `sh' for #<VagrantPlugins::CommunicatorWinRM::WinRMShell:0x0000010360c030> (NoMethodError)
    from /Users/nc014943/.vagrant.d/gems/gems/vagrant-omnibus-1.4.1/lib/vagrant-omnibus/action/install_chef.rb:144:in `installed_version'
    from /Users/nc014943/.vagrant.d/gems/gems/vagrant-omnibus-1.4.1/lib/vagrant-omnibus/action/install_chef.rb:47:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/warden.rb:34:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/builtin/provision.rb:80:in `call```

It should be set to ':cmd' but the windows guest detection is broken

def windows_guest?
  @machine.config.vm.guest.eql?(:windows)
end

@machine.config.vm.guest is nil so it's incorrectly detecting a non-windows guest.

@fabriciocolombo
Copy link

I have a machine running on a host windows and had no problems. My VagrantFile is like this:

 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
   config.vm.box = "ferventcoder/win2008r2-x64-nocm"  
   config.vm.communicator = "winrm"
   config.vm.guest = :windows
   ...
end

Vagrant 1.6.3
vagrant-omnibus (1.4.1)
Host Windows 7 Professional x64

@sneal
Copy link

sneal commented Aug 11, 2014

I would consider config.vm.guest = :windows a (good) workaround. Vagrant 1.6+ uses the communicator type to figure out if it should use WinRM or SSH, and thus shell type. Vagrant doesn't require you to set the guest type to windows like the old vagrant-windows plugin.

It would be good to have the check be consistent between any plugins and Vagrant core.

@vinyar
Copy link

vinyar commented Jan 28, 2015

+1 just hit this as well. Adding below fixed the error.

   config.vm.guest = :windows

With that said, I would wager a guess that guest :windows is an artifact left behind to avoid breaking people after vagrant started officially supporting windows (I think guest :windows essentially translates into communicator = 'winrm'. It may go away at some point.

@sneal
Copy link

sneal commented Jan 28, 2015

@vinyar Guest and Communicator seem similar, but are very different. For example, you can set the guest type to 'windows' and the communicator to 'ssh' assuming you've installed and configured an SSH server on your Windows guest.

@lonniev
Copy link

lonniev commented Jun 15, 2015

Thanks @sneal this also immediately fixed the omnibus issue for me for a Windows on Softlayer VM.

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

No branches or pull requests

6 participants