Skip to content

Instantly share code, notes, and snippets.

@Iristyle
Last active September 6, 2017 08:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Iristyle/000a80a98ce73590896a to your computer and use it in GitHub Desktop.
Save Iristyle/000a80a98ce73590896a to your computer and use it in GitHub Desktop.
Installing gems that require Ruby DevKit on a machine that has installed Puppet from MSI
  • Install Puppet from MSI
  • Note that the Ruby install path is something like c:\program files\puppet labs\puppet\sys\ruby
  • Install Chocolatey in PowerShell with iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
  • Close / re-open PowerShell
  • Install Ruby Devkit - choco install ruby2.devkit
  • Add Ruby to the beginning of the PATH using an 8.3 style path - $Env:PATH = "C:\Progra~1\Puppet~1\Puppet\sys\ruby\bin;" + $Env:PATH (NOTE: dir /x inside cmd.exe can be helpful to find 8.3 style paths)
    • If done correctly gem env should contain a line with RUBY EXECUTABLE: C:/PROGRA~1/PUPPET~1/Puppet/sys/ruby/bin/ruby.exe
    • This part is absolutely critical, so if gem env doesn't have a bunch of 8.3 style paths, you've done something wrong
  • Configure DevKit for use with our vendored Ruby
    • cd \DevKit-2.0-x64
    • ruby dk.rb init to generate config.yml
    • verify the generated config.yml and ensure that it has an entry for the vendored Ruby like below (and add it if it doesn't), then run ruby dk.rb install to associate the install with the devkit
---
 - C:/progra~1/puppet~1/puppet/sys/ruby/bin
  • Now gems with native code can be installed! Verify with gem install pry
@Iristyle
Copy link
Author

One of the artifacts of a broken DevKit install is a message like Error “invalid switch in RUBYOPT: -F (RuntimeError)” as described at http://stackoverflow.com/questions/16898286/error-invalid-switch-in-rubyopt-f-runtimeerror-is-shown-while-install-gems

@Iristyle
Copy link
Author

@ferventcoder
Copy link

I think there is a bit of an issue just adding PROGRA1, because it could be PROGRA2 (C:\Program Files (x86)) as well. Something to think about.

@Iristyle
Copy link
Author

Right - that's why I mentioned the bit about NOTE: dir /x inside cmd.exe can be helpful to find 8.3 style paths

@Iristyle
Copy link
Author

See comments at https://gist.github.com/Iristyle/aeda4c717a2ee48af1176db3bd9dac9a#gistcomment-2067749 about why this fails in AIO packages for puppet-agent 1.6.0 through puppet-agent 1.10.z

@jcoconnor
Copy link

A few notes and mods to the procedure above (at least relevant for ruby2.devkit v4.7.2.2013022402)

  1. You need to update $Env:PATH before installing the devout.
  2. The install location is C:\tools\DevKit2
  3. The correct text to put in the config.yml file is - C:/progra~1/puppet~1/puppet/sys/ruby

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