GigaPr
GigaPr

Reputation: 5386

Chef - ERROR: RuntimeError: Please set EDITOR environment variable

I've installed successfully chef on my workstation but when i am trying to create a role using the following command

knife role create startmeup

I get

ERROR: RuntimeError: Please set EDITOR environment variable

Any idea what the problem is?

Upvotes: 35

Views: 49506

Answers (11)

Rew Brian
Rew Brian

Reputation: 23

Knife prioritizes knife.rb over the environment variable.

It seems knife will default to vim (on my system, anyway) if no config is provided, so it is safe to omit the value until you're ready to configure your environment for a custom editor (in my case, a script).

Upvotes: 0

Mahesh Manandhar
Mahesh Manandhar

Reputation: 151

If you have notepad++ installed in your machine :

knife environment create startmeup -e notepad++

Upvotes: 0

Yun Zhao
Yun Zhao

Reputation: 193

There're a few ways to deal with the problem.

  1. set the environment variable $EDITOR. You can export it by export EDITOR=vim in shell, or put this line in files like .bashrc;

  2. pass the option -e vim (namely --editor vim)to the knife command. For example, you can do it like this:

    knife role create startmeup -e vim

  3. modify ~/.chef/knife.rb by add this line:

    knife[:editor] = "vim"

Upvotes: 4

vesuvious
vesuvious

Reputation: 2753

In your knife.rb file (~/.chef/knife.rb) add the following line for notepad++ :

knife[:editor] = "C:\\progra~2\\notepa~1\\notepad++.exe -nosession -multiInst"

or if you just want to use notepad

knife[:editor] = "notepad"

or emacs for GNU

knife[:editor] = "emacs"

Upvotes: 28

Harshal Vaidya
Harshal Vaidya

Reputation: 179

There is no explicit way to set the variable under knife.rb. Its good to export on your shell using $export EDITOR=vim (or any of those that you would like to keep).

Even without setting variable under knife.rf it works. Just export the EDITOR by setting the appropriate value.

Upvotes: -2

user2364290
user2364290

Reputation: 31

If you want to set it for that session, the command

set EDITOR="C:\Program Files (x86)\Notepad++\notepad++.exe"

works.

Upvotes: 3

Vitaliy
Vitaliy

Reputation: 51

I use something like this:

knife role create startmeup -e vi

Upvotes: 5

GigaPr
GigaPr

Reputation: 5386

Adding this entry to the knife config file worked for me

knife[:editor] = "Notepad"

Upvotes: 0

user3651353
user3651353

Reputation: 9

export EDITOR=vi   

In my case it worked.but for ubuntu14.o version vi editor backspace is not working.

Upvotes: 0

Tanmay
Tanmay

Reputation: 746

Just set your editor and it will work. In my case I use vim editor that's why my command was as follows:

export EDITOR=vim

Upvotes: 2

StephenKing
StephenKing

Reputation: 37600

You have to define EDITOR as environment variable.

Try

export EDITOR=$(which vi)

To persist this, add it to ~/.bashrc or ~/.bash_profile.

Upvotes: 46

Related Questions