Chef: ERROR: RuntimeError: Please set EDITOR environment variable

I've just setup a workstation on windows, and I'm getting the following error when I try to edit a data bag;

$ knife data bag edit tomhodder tomhodder
ERROR: RuntimeError: Please set EDITOR environment variable

tldr; SOLUTION: use a text editor that understands windows paths ("C:/Users/whatever/file"), rather than unix ("/C/Users/whatever/file"), e.g. export EDITOR=notepad


I've tried various combinations of vi, vim, /bin/vim and /bin/vi like so;

$ export EDITOR=/bin/vim

but its still rather stubbornly returning;

$ knife data bag edit tomhodder tomhodder
ERROR: RuntimeError: Please set EDITOR environment variable

Interestingly, I can't get it to bite on any of the options versions of providing the EDITOR, using "-e" or "--editor";

$ knife data bag edit tomhodder tomhodder -e vim
ERROR: RuntimeError: Please set EDITOR environment variable

$ knife data bag edit tomhodder tomhodder --editor /bin/vim
ERROR: RuntimeError: Please set EDITOR environment variable



just for the record, "/bin/vim" exists and is executable, and /bin is on the path.


So the relevant code is on line 161 of the file;
lib/chef/knife/core/ui.rb

$ knife data bag edit tomhodder tomhodder -VV 
DEBUG: Signing the request as tomhodder 
DEBUG: Sending HTTP Request via GET to api.opscode.com:443/organizations/class01 /data/tomhodder/tomhodder 
DEBUG: ---- HTTP Status and Header Data: ---- 
DEBUG: HTTP 1.1 200 OK 
DEBUG: server: ngx_openresty 
DEBUG: date: Mon, 20 May 2013 11:59:13 GMT 
DEBUG: content-type: application/json; charset=utf-8 
DEBUG: transfer-encoding: chunked DEBUG: connection: close 
DEBUG: status: 200 OK 
DEBUG: content-encoding: gzip 
DEBUG: ---- End HTTP Status/Header Data ---- 
DEBUG: decompressing gzip response

/gems/1.9.1/gems/chef-11.4.0/lib/chef/knife/cor e/ui.rb:161:in `edit_data': Please set EDITOR environment variable (RuntimeError )
from ...


So adding a debugging line;
msg("#{config[:editor]} #{tf.path}")
raise "Please set EDITOR environment variable" unless system("#{config[:editor]} 

produces this;
$ knife data bag edit tomhodder tomhodder
vim C:/Users/hodder/AppData/Local/Temp/knife-edit-110618731114210157125.js
ERROR: RuntimeError: Please set EDITOR environment variable

So that is indicating that the EDITOR requires a text editor that understands windoze paths. 

Doh! notepad it is then;

echo "export EDITOR=notepad"  >> ~/.bashrc

and then...
source ~/.bashrc
knife data bag edit tomhodder tomhodder


woo! success. (or as much success as 2 hours using windows 7 can be considered to be)