Ruby ';要求';:无法加载这样的文件--winrm(LoadError)

Ruby ';要求';:无法加载这样的文件--winrm(LoadError),ruby,chef-infra,Ruby,Chef Infra,我有以下脚本: require_relative 'embedded\lib\ruby\gems\1.9.1\gems\winrm-1.1.3\winrm.rb' IP=ARGV[0] USER=ARGV[1] endpoint = "http://#{IP}:5985/wsman" winrm = WinRM::WinRMWebService.new endpoint, :plaintext, user: USER, pass: 'supersecret', basic_auth_only:

我有以下脚本:

require_relative 'embedded\lib\ruby\gems\1.9.1\gems\winrm-1.1.3\winrm.rb'

IP=ARGV[0]
USER=ARGV[1]
endpoint = "http://#{IP}:5985/wsman"
winrm = WinRM::WinRMWebService.new endpoint, :plaintext, user: USER, pass: 'supersecret', basic_auth_only: true
winrm.set_timeout 1800

installer_file = "c:\\Users\\#{USER}\\Downloads\\chef_client.msi"
installer_cmd = "msiexec /qn /i #{installer_file} ADDLOCAL=\"ChefServiceFeature,ChefClientFeature\""

puts 'Installating Chef'
install_output = winrm.cmd installer_cmd

sleep 300
puts 'Configuring Chef'
winrm.cmd %Q(mv c:\\Users\\#{USER}\\Downloads\\client.rb c:\\chef\\client.rb)
winrm.cmd %Q(mv c:\\Users\\#{USER}\\Downloads\\chef-validator.pem c:\\chef\\validation.pem)
winrm.cmd 'net start chef-client || net start chef-client'
无论何时尝试运行它,我都会得到:
'require':无法加载这样的文件--winrm(LoadError)


我正在使用Ruby193和Chef的设置,所以也许这与我的盒子上有193和Chef的任何东西有关我这辈子都没法让它工作。我能够安装winrm gem(我想是吧?),但我不知道如何从我的脚本访问它。

你就不能
要求“winrm”
?此外,Ruby的
require
采用了一个没有
.rb
扩展名的路径,因此您可能会幸运地使用
require\u relative'.\winrm-1.1.3\winrm'
Ruby还在路径“embedded/lib/…”中使用前斜杠。也尝试更改它。winrm应由chef自动加载。只需在Windows计算机上使用“chef”,即可获得WinRM。