What’s Mining: Chef Integration

Hello everyone,

I’d like to introduce a plugin for RubyMine and IDEA that provides Chef support. It’s compatible with the last RubyMine Tsubaki EAP and Intellij IDEA 14 EAP.

Following the main concepts of Chef the plugin introduces cookbooks, recipes and resources in the IDE. It provides marking/detection options for a cookbook and code insight for a resource and for its attributes. Please note you need to install Chef gem before you start.

Cookbooks

Cookbooks are presented in RubyMine as a new kind of the project source root. So to define a directory as a cookbook you are to mark it as ‘Cookbook’ source root. This action is available via context menu in the Project View as well as in the Settings | Project Structure:

chef_1

 

If a directory contains ‘recipes’ folder with a ruby file inside, the directory is detected as a cookbook and you’re asked whether to add it or not:

chef_2

Resources

Since the folder is marked as a cookbook, code insight is available f0r any ruby file inside the ‘recipes’. E.g. one can complete any Chef resource or navigate to its definition into the Chef library:

chef_3

Attributes

Resource’s own attributes and inherited ones are also available inside the resource code block:

chef_4

Wherever it’s possible RubyMine suggests attribute arguments such as allowed actions for the action attribute; actions for the notifies and subscribes; all boolean arguments; and many more.

We would be glad if you try the plugin and share your feedback.  Please don’t hesitate to ask any questions here in the comments or on our forum.


Develop with pleasure!
JetBrains RubyMine Team

This entry was posted in Feature, What's New (EAP) and tagged , . Bookmark the permalink.

30 Responses to What’s Mining: Chef Integration

  1. Andi S. says:

    Well, this got me excited for a second, but then I noticed I had a different Chef in mind… oh well :/

  2. Yulian S. says:

    That was a long-awaited feature
    Thank you guys!

  3. Daryl Robbins says:

    Fantastic addition to Ruby Mine! I have been looking for IDE support for Chef for a long time. It’s painful not having access to good code completion. Keep up the good work!

  4. Justin Schuhmann says:

    Can’t get this working in IntelliJ IDEA Ultimate 14 EAP…
    1. Installed the plugin
    2. when running sudo gem install chef
    -Building native extensions. This could take a while…
    ERROR: Error installing chef:
    ERROR: Failed to build gem native extension.

    /opt/chef/embedded/bin/ruby extconf.rb
    creating Makefile
    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/libyajl2-1.0.1/ext/libyajl2
    extconf.rb:104:in makemakefiles': unhandled exception
    from extconf.rb:143:in

    Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/libyajl2-1.0.1 for inspection.
    Results logged to /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/libyajl2-1.0.1/ext/libyajl2/gem_make.out

    i’m running on mac os x, I presume i need this gem (even though i have chef installed) because i can’t get the ide to allow me to select items in the project view to have a Cookbook or chef tag.

  5. Justin Schuhmann says:

    I now have the gem install chef working….
    However I still don’t have an option under Project Structure to tag my cookbooks

  6. Justin Schuhmann says:

    To get this working I first had to in IntelliJ IDEA EAP 14 Terminal run:
    sudo gem install chef

    I then loaded the chef-repo folder:
    I have to open a recipe inside a cookbook and my cookbooks were auto detected.

    I still don’t have intellisense

    Note: On mac os x if you get a compile error with gem install chef
    run the following:
    sudo gcc -v
    then go to the bottom using space
    then type accept

    • Justin Schuhmann says:

      It doesn’t seem to understand anything chef as well

      • Dmitry Krasilschikov says:

        Hello, Justin!

        Thank you for details feedback.

        > It doesn’t seem to understand anything chef as well
        Please clarify the problem.

        Since the ‘chef’ gem has been installed it should be automatically added as ‘external library’. Also the code completion of the chef default resources, attributes and some attribute parameters should appear in all “.rb” files under the marked ‘cookbook’ directory, shouldn’t they?

  7. Does it work well with ChefDK? And with rbenv for ChefDK too?

    Thanks, M.

  8. Dmitry Krasilschikov says:

    Hello, Martin,

    the Chef plugin of RubyMine uses the ‘Chef’ gem in the selected Ruby SDK.

    Please note that the “Chef” gem is pre-installed into the embedded into the ChefDK Ruby SDK (by default it’s ‘/opt/chefdk/embedded/bin/ruby’) so you can just add it into the RubyMine and the ‘Chef’ plugin will use it.

    Sure, the same you can do in the case of the ChefDK managed by rbenv. Please see also the ‘rbenv support’ reference.

  9. This is a really great plugin that I mostly got working. Thanks so much for your hard work!

    One question: How does the plugin handle cookbook dependencies.

    I have a cookbook with a Berksfile declared with a dependency on the windows and dsc cookbooks. It doesn’t appear that my dsc_resource or powershell_script resources are being recognized by RubyMine. Is this expected?

  10. Darryl says:

    Hey,

    I still can’t get code completion to work. I’ve pointed at my chefdk ruby, the cookbook is getting recognised and flagged as a cookbook root, however I get no chef code completion like in the Resources screenshot.

    Any ideas?

    I’m on RubyMine 7.0.4 with ChefDK 0.4.0.

    Cheers,
    Darryl

  11. Daniel Zabel says:

    Hello Dmitry,

    is it possible to configure excludes for cookbook detection?

    For example: berks-cookbooks

    Cheers,

    Daniel

  12. Hello Dmitry,

    could you please help to disable some rules of FoodCritic delivered with plugin, where I can find FC config or run arguments?

    Thanks.

  13. Hemant says:

    Does ruby mine integrate with Test Kitchen for running rspec tests ?

  14. Yan says:

    Tnx for good info

  15. Gene Wood says:

    Dmitry, should this Chef plugin still work here in 2017?

    If using RubyMine 2017.2.4
    with the plugin “Chef integration” of version 172.3317.67
    And chefdk’s ruby-2.4.2-p198 interpreter

    And i create a new directory

    mkdir testing
    cd testing

    and in that directory a new cookbook by running

    chef generate cookbook examplecookbook

    And I open “testing” in RubyMine

    And I open testing/examplecookbook/recipes/defualt.rb

    The plugin prompts me to setup two cookbooks

    examplecookbook
    build_cookbook

    And I click “Configure Cookbooks”

    and uncheck build_cookbook so I can setup examplecookbook

    I get no chef plugin functionality (highlighting, autocomplete, etc)

    Since this is the most basic setup I can think of, am I overlooking something or does this plugin just no longer work with modern chef and/or modern RubyMine?

  16. Jim Croft says:

    YT issue asking for Berkshelf support has been open for four years! If Jetbrains have no interest in maintaining this plugin can it be open sourced so others can pick it up?

Leave a Reply

Your email address will not be published. Required fields are marked *