1

I'm new to Chef. Today, while study role in chef, I created a test role rb file --

name "reposerver"
description "repo server for sles12.4,12.5"
run_list "recipe[e]"

Then I run knife command to create this role, but failed with --

C:\Work\chef-repo>knife role create from file roles\reposerver.rb
ERROR: RuntimeError: Please set EDITOR environment variable. See https://docs.chef.io/knife_setup/ for details.

After search, I found this -- Chef - ERROR: RuntimeError: Please set EDITOR environment variable

So follow it, I modify my config.rb like this --

current_dir = File.dirname(__FILE__)
log_level                :info
log_location             STDOUT
node_name                "eisenwang"
client_key               "#{current_dir}/eisenwang.pem"
chef_server_url          "https://api.chef.io/organizations/eisen"
cookbook_path            ["#{current_dir}/../cookbooks"]
knife[:editor]    = "C:\\Program Files (x86)\\IDM Computer Solutions\\UltraEdit\\Uedit32.exe"

But that "knife role create from file roles\reposerver.rb" still fails with same error... Is there any wrong in my config.rb? Or it should not be in C:\users\username\.chef ? Thanks for your reply.

Regards

Eisen

EisenWang
  • 189
  • 1
  • 10

2 Answers2

1

After testing, I found the issue -- It's due to ultraedit is not a blocking text editor, once file is opened, ultraedit will not hold the file handler anymore. So knife can't find it updated or not. So once I changed it to --

knife[:editor] = "notepad"

Issue fixed.

EisenWang
  • 189
  • 1
  • 10
  • *UltraEdit* has the configuration setting __Lock file for write while editing__ if *knife* is really checking the file sharing access permissions of the opened file. But I think, this is not done. I suppose that *knife* checks if the editor process finished. The default configuration is that on start of *UltraEdit* with a file name as argument, *UltraEdit* checks if another instance of *UltraEdit* is already running. In this case the arguments (file names) are passed to the already running instance of *UltraEdit* and the newly started instance of *UltraEdit* closes itself immediately. – Mofi May 14 '22 at 12:26
  • That configuration is useful for *UltraEdit* users who want to edit all files in same instance of *UltraEdit*, but it is not good for other applications which expect the started text editor process is running as long as the text file is edited by the user. There are multiple configuration settings in *UltraEdit* to handle such use cases, too. There can be enabled the configuration setting __Allow multiple instances__ to work with multiple instances of *UltraEdit*. – Mofi May 14 '22 at 12:29
  • The *UltraEdit* configuration setting __Maintain separate process for each file opened from external application__ is for users of *UltraEdit* who want to use always just a single instance of *UltraEdit* for editing text files, but where it is necessary that an *UltraEdit* instance started by another process like *knife* with one or multiple files to edit keeps running in background, although the file names are passed to already running instance of *UltraEdit* for editing. The background *UltraEdit* instance started by *knife* closes on passed file(s) are closed in main *UltraEdit* instance. – Mofi May 14 '22 at 12:30
  • *UltraEdit* has also the command line option `/fni` (force new instance). If *knife* supports the variable with a value like `"C:\\Program Files (x86)\\IDM Computer Solutions\\UltraEdit\\Uedit32.exe" /fni` to start *UltraEdit* with the command line parameter `/fni` and the file name of the text file to edit appended, this could be another solution. Otherwise a Windows batch file could be specified as editor which has just the command line `@"C:\Program Files (x86)\IDM Computer Solutions\UltraEdit\Uedit32.exe" /fni %*`. – Mofi May 14 '22 at 12:31
  • @Mofi Thanks a lot. You teached me a lot about Ultraedit. – EisenWang May 14 '22 at 12:44
0

Set a windows environment variable called EDITOR pointing to the UltraEdit executable. That should fix it.

misteralexander
  • 448
  • 2
  • 7
  • 19
  • 1
    Thanks. But I found it's not the issue -- the issue is -- ultraedit is not a blocking text editor, so the knife will skip it. When I change it to notepad-- it works. :) Thanks again. – EisenWang May 12 '22 at 01:19