Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmanfunky/53c57e7df12e5a1e0776 to your computer and use it in GitHub Desktop.
Save gmanfunky/53c57e7df12e5a1e0776 to your computer and use it in GitHub Desktop.
How to almost completely build chef-dk on windows with Ruby 1.9.3. chef-dk currently depends on Ruby >= 2.0. Ruby 1.9.3 is end-of-life early next year.
WARNING: chef-dk currently depends on Ruby >= 2.0 , so these steps are mostly just in-case we have to fall-back and make chef-dk work on Ruby 1.9.3 someday.
Pre-req: you might have to sanitize a pre-existing ruby and git environment.
Reset PATH environment variable to exclude any \Git\bin folders or other “unix utils” which may pollute your dev environment. It may seem all okay until you get 20 minutes into a compile and tar.exe takes a stackdump.
Install ruby 1.9.3 and devkit. I used Chocolatey Nuget package manager.
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
cinst git.install -notSilent
DO elect to adjust path to “Run Git from the Windows Command Prompt”
DO NOT elect to put unix tools in the path. This may conflict with the dev environment. tar.exe may stackdump in fecode build process.
git config --global user.email YOURNAME@example.com
git config --global user.name "Your Name"
cinst ruby -version 1.9.3.48400
WARNING: Ruby 1.9.3 is scheduled to be End of Life in Feb 2015
exit and then start new cmd.exe window to get new path
cinst ruby.devkit
#Avoid installations of gem documentation
(echo install: --no-rdoc --no-ri && echo update: --no-rdoc --no-ri) >> %USERPROFILE%\.gemrc
Add other needed command line utilities (gzip, tar) to devkit
Download Win32 gzip: http://gnuwin32.sourceforge.net/downlinks/gzip-bin-zip.php
Extract gzip.exe to c:\DevKit\bin
Download Win32 tar: http://gnuwin32.sourceforge.net/downlinks/tar-bin-zip.php
Extract tar.exe to c:\DevKit\bin
Download Win32 tar dependencies: http://gnuwin32.sourceforge.net/downlinks/tar-dep-zip.php
Extract just libintl-2.dll to c:\DevKit\bin
Download 7zip gui package to get 7z.exe which omnibus gem uses http://downloads.sourceforge.net/sevenzip/7z920-x64.msi
Edit your environment variables to put C:\Program Files\7-Zip in the path.
git clone https://github.com/opscode/omnibus-chef
cd omnibus-chef
gem install bundler
bundle install --binstubs
Changed /config/projects/chefdk-windows.rb to specify
override :berkshelf, version: "master"
#I encountered a crazy dissapearing PATH= environment variable problem.
#ruby.exe (Mixin:ShellOut or something) will start make.exe with both Path= and PATH= environment values.
#This results in unpredictable behavior by tools.
#Indeed, make.exe will start gcc.exe and as.exe in a way that will clobber the PATH= value and cuase weird build errors.
#Add line below to remote PATH from cmd_args environment
In builder.rb
def bundle_bust(*cmd_args)
if cmd_args.last.is_a?(Hash)
cmd_args = cmd_args.dup
cmd_opts = cmd_args.pop.dup
cmd_opts[:env] = cmd_opts[:env] ? BUNDLER_BUSTER.merge(cmd_opts[:env]) : BUNDLER_BUSTER
+ cmd_opts[:env].delete("PATH") #Not sure how this gets here, but it screws up windows builds
cmd_args << cmd_opts
#pick up the devkit environment
c:\DevKit\devkitvars.bat
ruby bin/omnibus build project chefdk
#or maybe?: bundle exec omnibus build project chefdk
@gmanfunky
Copy link
Author

I think i've identified a place to put a fix for the duplicate environment variable bug.
https://github.com/opscode/mixlib-shellout/blob/master/lib/mixlib/shellout/windows.rb#L227-241
In def inherit_environment

Maybe test against the .upcase of every existing ENV['key'] ?

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