Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

Iristyle commented Aug 12, 2015

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

This comment has been minimized.

@ferventcoder

This comment has been minimized.

Copy link

ferventcoder commented Aug 12, 2015

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

This comment has been minimized.

Copy link
Owner Author

Iristyle commented Aug 13, 2015

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

This comment has been minimized.

Copy link
Owner Author

Iristyle commented Apr 19, 2017

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

This comment has been minimized.

Copy link

jcoconnor commented May 12, 2017

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
You can’t perform that action at this time.