Chef Knife not saving changes with editor

953 views Asked by At

I want to create a role with knife. So I run:

> knife role create beautifulprayer
ERROR: RuntimeError: Please set EDITOR environment variable

No problem! Just add the editor. Afterwards:

> knife role create beautifulprayer

This opens the editor that I have set (subl) and goes ahead once the editor is open and propagates the call to the chef server, resulting in Created role[beautifulprayer] although the editor is still open and I have not saved anything. This happens with editing too where it results to Object unchanged, not saving while the editor is still open and no save happened.

This does NOT happen though when I use vim because knife waits for me to close VIM and then propogates the call to chef server. I'd like to use sublime but this isn't currently working because any changes and saving with sublime are not propagated or detected by knife.

1

There are 1 answers

1
Roland On BEST ANSWER

You need to call your editor to "block" the current process and not fork another one. Usually this is somewhat described as "no fork", "foreground" or "wait" option:

Examples:

Sublime Text

export EDITOR="subl -w"

Atom:

export EDITOR="atom -f"

MacVim:

export EDITOR="mvim -f"

TextMate 2:

export EDITOR="mate -w"

When you've done your change, you need to close the editor and knife will pick up the change.