Giter Site home page Giter Site logo

rbenv-chefdk's Introduction

rbenv-chefdk: Use ChefDK with rbenv

This plugin lets you treat ChefDK as another version in rbenv.

deprecated ChefDK has been replaced by Chef Workstation. See the rbenv-chef-workstation plugin instead.

Requirements

  • ChefDK installed in /opt/chefdk

Installation

From GitHub

To install rbenv-chefdk, clone this repository into the $(rbenv root)/plugins directory.

cd $(rbenv root)/plugins
git clone <url>

On macOS

On macOS, you can use brew to install:

brew install rbenv-chefdk

Warning: If you've previously installed ChefDK which led you to using this plugin, you will want to remove the profile changes recommended in the ChefDK install instructions or in the Homebrew info gist. Otherwise rbenv or ChefDK will not work correctly.

Then create an empty directory in $(rbenv root)/versions called chefdk:

$ mkdir "$(rbenv root)/versions/chefdk"

Finally, change to the new chefdk version and run rbenv rehash.

$ rbenv shell chefdk
$ rbenv rehash
$ rbenv which ruby
/opt/chefdk/embedded/bin/ruby

That's it!

Troubleshooting

If you are having problems, try running sanity-check.sh:

$ $SHELL "$(rbenv root)/plugins/rbenv-chefdk/sanity-check.sh"

Frequently Asked Questions

Hey, what happened to gem?

With the ChefDK you have to use chef gem instead.

Why don't you include /opt/chefdk/embedded/bin?

We don't fully include the /opt/chefdk/embedded/bin directory because it'll break your system in subtle ways.

/opt/chefdk/embedded/bin has commands like clear, tput, xsltproc, and xz. These are commands that are part of your system and are only included in ChefDK so it gets reliable results across platforms.

If we made shims of these commands, your system might break when not using chefdk and can produce unexpected results even if you were using chefdk if your version of these commands are different (e.g. Gnu vs. BSD or version).

Why not just symlink /opt/chefdk/embedded to $(rbenv root)/versions/chefdk?

For the same reason we don't include /opt/chefdk/embedded/bin: It breaks systems commands in unexpected ways.

Rbenv isn't working or is using gems from the wrong place

Make sure you undid any changes recommended by the ChefDK install instructions or in the Homebrew info gist.

Specifically, make sure you aren't calling chef shell-init anyplace in your shell startup files.

"can't find executable chef (Gem::Exception)"

This is probably because you are using rbenv-bundle-exec.

You'll have to tell rbenv-bundle-exec to ignore a bunch of binaries that are only in ChefDK:

echo chef >> ~/.no_bundle_exec
echo berks >> ~/.no_bundle_exec

Questions?

You can reach me at docwhat.org or as docwhat on Freenode IRC.

License

Copyright (c) 2015,2016 Christian Höltje - Released under the MIT License (see the LICENSE file)

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit
  • Send me a pull request. Bonus points for topic branches.

rbenv-chefdk's People

Contributors

docwhat avatar gordonbondon avatar mrjcleaver avatar webbob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rbenv-chefdk's Issues

" gem executables will not run."

Should I still see: WARNING you don't have .chefdk/gem/ruby/2.1.0/bin in your PATH ?

~/.bash_profile

rbenv local chefdk
eval "$(rbenv init -)"
#eval "$(chef shell-init bash)"                                                                                              

export PATH="$HOME/bin:$PATH"

`gem install` and `chef gem install` don't work

After installing this plugin, I can't figure out how to install gems into the ChefDK ruby. I've tried gem install and chef gem install, but they both result in the same error:

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /opt/chefdk/embedded/lib/ruby/gems/2.1.0 directory.

My understanding is that ChefDK's gem shouldn't even be trying to install new gems there. It should be using ~/.chefdk instead.

Installation ~/.rbenv/plugins & Homebrew

Interesting! I didn't know rbenv did plugins. rbenv/rbenv#691

Some points about instructions:

This is usually ~/.rbenv/plugins or /usr/local/var/rbenv/plugins if you use Homebrew on OS X.

I don't know why, but even though I do use Homebrew on OS X, it looks like this is ~/.rbenv/plugins for me.

Further, I had to make this ~/.rbenv/plugins - it would be nice to be able to brew install rbenv-chefdk instead of this:

martincleaver@martincaversmbp:~ 09:34:07 508$ cd .rbenv/
martincleaver@martincaversmbp:~/.rbenv 09:37:35 509$ ls
shims    version  versions
martincleaver@martincaversmbp:~/.rbenv 09:37:35 510$ mkdir plugins
martincleaver@martincaversmbp:~/.rbenv 09:37:38 511$ cd plugins/
martincleaver@martincaversmbp:~/.rbenv/plugins 09:37:40 512$ ls
martincleaver@martincaversmbp:~/.rbenv/plugins 09:37:40 513$ git clone https://github.com/docwhat/rbenv-chefdk.git
Cloning into 'rbenv-chefdk'...
remote: Counting objects: 22, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 22 (delta 2), reused 20 (delta 0)
Unpacking objects: 100% (22/22), done.
Checking connectivity... done.
martincleaver@martincaversmbp:~/.rbenv/plugins 09:38:47 514$ ls
rbenv-chefdk

Not least because this could be clearer:

Then symlink your ChefDK embedded directory into your $RBENV_ROOT/versions directory. For example:
mkdir "$RBENV_ROOT/versions/chefdk"

So, mkdir a symlink does not make... did you mean something like:

martincleaver@martincaversmbp:~/.rbenv/versions 09:23:41 850$ ls -la
total 8
drwxr-xr-x  5 martincleaver  staff  170  1 Dec 15:16 .
drwxr-xr-x  5 martincleaver  staff  170  6 Nov 01:59 ..
drwxr-xr-x  6 martincleaver  staff  204  6 Nov 01:56 1.9.3-p125
drwxr-xr-x  6 martincleaver  staff  204  1 Dec 15:16 1.9.3-p327
lrwxr-xr-x  1 martincleaver  staff   20  6 Nov 02:11 chefdk -> /opt/chefdk/embedded

i.e.

martincleaver@martincaversmbp:~/.rbenv/versions 09:48:55 865$ ln -s /opt/chefdk/embedded chefdk

rbenv-chefdk appears to be incompatible with rbenv-bundle-exec

With both plugins installed to ~/.rbenv/plugins, attempts to execute chef-specific commands with the embedded ruby results in the following error:

/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:355:in 'block in replace_bin_path': can't find executable chef (Gem::Exception) from /opt/chefdk/embedded/bin/chef:22:in

This definitely impacts both the chef and berks executable files, I'm not sure on others.

Removing the rbenv-bundle-exec plugin restores the functionality of the chef executables.

What about GEM_PATH?

Should GEM_PATH and GEM_ROOT be set?

I'm assuming the recommendation is never to thereafter chef shell-init bash, but that also sets those variables.

BTW: are you at ChefConf this week? I am.

Provide an ENV checker utility

So... it turns out that Ruby gets extremely confused if chefdk is in the path both via rbenv and directly, especially if it's invoked via bundle install.

I suspect that a "check I did it right" utility (checkenv.sh or similar) would go a long way to help n00bs from messing up.

I think it needs to check for GEM_PATH, GEM_ROOT, and then the presence of rbenv shims in PATH alongside chefdk anything else that could be checked.

Consider it an anti pattern checker... would have helped with #2 as well.

add support for chef-dk versions (ensure team uses same version)

One of the biggest problems that ChefDK sought to solve was the dependency nightmare with the various components used from development through test to deployment into production.

The downside is that solving that problem meant you can no longer rely on a Gemfile and Gemfile.lock to ensure an entire team is using the same version of the tools used to test code (including CI tools which use test-kitchen). It should be obvious to anyone who builds and deploys software to production that not having reproducible builds and tests is a problem. For example, we've seen cookbooks that once passed test-kitchen suddenly fail because it was dynamically pulling in the latest version of tools like busser. So a project may pass for one member of the team and not another if they're on different versions of ChefDK.

To restore the ability to lock members of a team into using the same chef ecosystem, it would be great if rbenv-chefdk could support something like this:

a .ruby-version file in a cookbook's parent directly would contain chefdk-1.5, chefdk-1.6, etc.

if a user has a different version of chef-dk installed than the one specified in .ruby-version, an error will be thrown.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.