WARNING: No knife configuration file found


My apologies for the new question.

I am running Chef on Windows and trying to dial in my workstation configuration. If I run ‘knife’ from anywhere other than the directory where knife.rb is located, I get the following error…

WARNING: No knife configuration file found

But the command works sometimes. For example, I was able to use knife to verify that wsman is enabled on a node.

C:\WINDOWS\system32>knife wsman test nciltschef01 --manual-list
WARNING: No knife configuration file found
Connected successfully to nciltschef01 at http://nciltschef01:5985/wsman.

On the other hand, if I try to get a client list, it fails because it seems to be looking in c:\chef… for the .pem files.

C:\WINDOWS\system32>knife client list
WARNING: No knife configuration file found
WARN: Failed to read the private key C:\chef\client.pem: #<Errno::ENOENT: No such file or directory @ rb_sysopen - C:\chef\client.pem>
ERROR: Your private key could not be loaded from C:\chef\client.pem
Check your configuration file and ensure that your private key is readable

What do I need to configure so that knife knows where to find knife.rb?


Chef tries a number of strategies to find your config. In general, it will try and use a config.rb or knife.rb, in a set of directories. In order, it:

  • uses a config file you’ve explicitly given (ie: knife -c some\config\knife.rb)
  • uses the KNIFE_HOME environment variable to specify a config directory.
  • uses a config.rb or knife.rb in the current directory.
  • searches upwards from your current directory to try and find a config directory. Given a path C:\WINDOWS\System32, it will try and find config.rb or knife.rb in: C:\WINDOWS\System32\.chef, C:\WINDOWS\.chef, C:\.chef
  • looks for a .chef directory in the user’s Home directory.
  • falls back to defaults

You’re seeing Chef try to load the default client.pem, which is C:\chef\client.pem or /etc/chef/client.pem.

Most people have a default .chef directory in their home directory, and then if they need more specific configs they have those in the right part of their directory structure.

I thought this was documented on the docs site, but it seems not. I’ll get that fixed.




Thank you for your response.

Where do I set the KNIFE_HOME variable?

Does it go into the Powershell profile (.ps1 file) and use the same $env: syntax?

i.e. $env:KNIFE_HOME = “C:\knife” where c:\knife contains knife.rb?


Yes, that would be a good approach.



That did not work.

Here is the error…

C:\WINDOWS\system32>knife list client
ERROR: Attempt to use relative path ‘client’ when current directory is outside the repository path.
ERROR: Current working directory is ‘C:/WINDOWS/System32’.
[ref] cannot be applied to a variable that does not exist.
At C:\opscode\chefdk\modules\chef\chef.psm1:187 char:3

  • $success = [Chef.Kernel32]::GetExitCodeProcess($pi.hProcess, [ref] $global:LAS …
  •   + CategoryInfo          : InvalidOperation: (global:LASTEXITCODE:VariablePath) [], RuntimeException
      + FullyQualifiedErrorId : NonExistingVariableReference

Here is the variable that I added to my Powershell profile

$env:KNIFE_HOME = “C:\Users\darmstrong\chef-repo.chef”

That directory has both the knife.rb and *.pem files for my user and org.