错误:运行时错误:请设置编辑器环境变量

时间:2022-06-01 20:04:21

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

我已经在我的工作站上成功地安装了chef,但是当我尝试使用以下命令创建角色时

knife role create startmeup

I get

我得到

ERROR: RuntimeError: Please set EDITOR environment variable

错误:运行时错误:请设置编辑器环境变量

Any idea what the problem is?

你知道问题出在哪里吗?

9 个解决方案

#1


35  

You have to define EDITOR as environment variable.

必须将编辑器定义为环境变量。

Try

试一试

export EDITOR=$(which vi)

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

若要持久,请将其添加到~/中。bashrc或(~ / . bash_profile。

#2


28  

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

在你的刀。rb文件(~/.chef/knife.rb)添加了以下一行:

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

或为GNU emacs

knife[:editor] = "emacs"

#3


4  

I use something like this:

我用的是这样的:

knife role create startmeup -e vi

#4


3  

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

如果您想为会话设置它,命令

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

works.

的工作原理。

#5


2  

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

只要设置你的编辑器,它就会工作。在我的例子中,我使用了vim编辑器,这就是为什么我的命令如下:

export EDITOR=vim

#6


1  

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. 设置环境变量$EDITOR。您可以在shell中通过export EDITOR=vim导出它,或者将这一行放到.bashrc这样的文件中;
  3. pass the option -e vim (namely --editor vim)to the knife command. For example, you can do it like this:

    将选项-e vim(即编辑器vim)传递给刀具命令。例如,你可以这样做:

    knife role create startmeup -e vim

    刀的角色创造了startmeup -e vim。

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

    修改~ / .chef /刀。rb加上这一行:

    knife[:editor] = "vim"

    刀[:编辑器]= "活力"

#7


0  

export EDITOR=vi   

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

就我而言,它起作用了。但对于ubuntu14。o版本vi编辑器退格不起作用。

#8


0  

Adding this entry to the knife config file worked for me

将这个条目添加到刀具配置文件对我来说很有用

knife[:editor] = "Notepad"

#9


-2  

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).

没有明确的方法将变量设置为knife.rb。使用$export EDITOR=vim(或您希望保留的任何内容)在您的shell上进行导出是有好处的。

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

甚至不用在刀下设置变量。射频它的工作原理。只需通过设置适当的值来导出编辑器。

#1


35  

You have to define EDITOR as environment variable.

必须将编辑器定义为环境变量。

Try

试一试

export EDITOR=$(which vi)

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

若要持久,请将其添加到~/中。bashrc或(~ / . bash_profile。

#2


28  

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

在你的刀。rb文件(~/.chef/knife.rb)添加了以下一行:

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

或为GNU emacs

knife[:editor] = "emacs"

#3


4  

I use something like this:

我用的是这样的:

knife role create startmeup -e vi

#4


3  

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

如果您想为会话设置它,命令

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

works.

的工作原理。

#5


2  

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

只要设置你的编辑器,它就会工作。在我的例子中,我使用了vim编辑器,这就是为什么我的命令如下:

export EDITOR=vim

#6


1  

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. 设置环境变量$EDITOR。您可以在shell中通过export EDITOR=vim导出它,或者将这一行放到.bashrc这样的文件中;
  3. pass the option -e vim (namely --editor vim)to the knife command. For example, you can do it like this:

    将选项-e vim(即编辑器vim)传递给刀具命令。例如,你可以这样做:

    knife role create startmeup -e vim

    刀的角色创造了startmeup -e vim。

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

    修改~ / .chef /刀。rb加上这一行:

    knife[:editor] = "vim"

    刀[:编辑器]= "活力"

#7


0  

export EDITOR=vi   

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

就我而言,它起作用了。但对于ubuntu14。o版本vi编辑器退格不起作用。

#8


0  

Adding this entry to the knife config file worked for me

将这个条目添加到刀具配置文件对我来说很有用

knife[:editor] = "Notepad"

#9


-2  

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).

没有明确的方法将变量设置为knife.rb。使用$export EDITOR=vim(或您希望保留的任何内容)在您的shell上进行导出是有好处的。

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

甚至不用在刀下设置变量。射频它的工作原理。只需通过设置适当的值来导出编辑器。