Install ChefDK on Mac

From Bonus Bits
Jump to: navigation, search

Purpose

This article gives the steps to install ChefDK on Mac OS X Yosemite.


Install

  1. Download ChefDK
  2. Run DMG file

Proxy (Optional)

Add the following to your ~/.bash_profile

export http_proxy=http://username:password@[IP of Proxy Server]:[port]
export https_proxy=https://username:password@[IP of Proxy Server]:[port]
OR
Setup Charles Proxy


Set Environment Variables

Add environment variables to your BASH profile to set pathing for all the embedded items that come with ChefDK. Such as, Ruby, irb, gem, kitchen, knife, berks, etc. So you don't have to preface all commands with chef exec.

Option 1 (Recommended)

Add the chef shell-init bash eval to your BASH Profile.

echo 'eval "$(chef shell-init bash)"' >> ~/.bash_profile
OR
Manually add to the profile.
vim ~/.bash_profile
eval "$(chef shell-init bash)"

Option 2 (Statically Add)

Another option is to manually add the exports that are added into memory by the chef shell-init bash command. The only issue is if they change pathing in the future such as the 2.1.0 folder then you'd have to adjust your manual entries. So it's preferred to use the first option.

echo 'export PATH="$PATH:/opt/chefdk/embedded/lib/ruby/gems/2.1.0/bin:$HOME/.chefdk/gem/ruby/2.1.0/bin"'
echo 'export GEM_ROOT="/opt/chefdk/embedded/lib/ruby/gems/2.1.0"'
echo 'export GEM_HOME="$HOME/.chefdk/gem/ruby/2.1.0"'
echo 'export GEM_PATH="/opt/chefdk/embedded/lib/ruby/gems/2.1.0:$HOME/.chefdk/gem/ruby/2.1.0"'
OR
Manually add to the profile.
vim ~/.bash_profile
export PATH="$PATH:/opt/chefdk/embedded/lib/ruby/gems/2.1.0/bin:$HOME/.chefdk/gem/ruby/2.1.0/bin"
export GEM_ROOT="/opt/chefdk/embedded/lib/ruby/gems/2.1.0"
export GEM_HOME="$HOME/.chefdk/gem/ruby/2.1.0"
export GEM_PATH="/opt/chefdk/embedded/lib/ruby/gems/2.1.0:$HOME/.chefdk/gem/ruby/2.1.0"

Gnome-sticky-notes-applet Do no use ~/ to point to your home directory. It will not resolve it correctly. $HOME or full path works.


Upgrade

I find it's best to remove the old version before upgrading so you don't end up with old gems etc.

  1. Download ChefDK
  2. Remove old ChefDK
    sudo rm -rf /opt/chefdk
    
  3. Remove old added/upgraded gems from home directory (OPTIONAL)
    rm -rf ~/.chefdk
    
  4. Run DMG file


Uninstall

  1. To remove installed files
    sudo rm -rf /opt/chefdk
    
  2. To remove the system installation entry
    sudo pkgutil --forget com.getchef.pkg.chefdk
    
  3. To remove the symlinks under /usr/bin
    sudo find /usr/bin -lname '/opt/chefdk/*' -delete
    
  4. Remove user settings, gems etc.
    rm -rf $HOME/.chefdk