# Getting this error when using knife command

**URL:** <https://discourse.chef.io/t/getting-this-error-when-using-knife-command/6115>\
**Category:** Chef Infra (archive)\
**Created:** [December 24, 2014, 4:44pm UTC](https://discourse.chef.io/t/getting-this-error-when-using-knife-command/6115 "2014-12-24T16:44:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dharmesh\_patel](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@dharmesh\_patel](https://discourse.chef.io/u/dharmesh_patel)\
**Post date:** [December 24, 2014, 4:44pm UTC](https://discourse.chef.io/t/getting-this-error-when-using-knife-command/6115/1 "2014-12-24T16:44:53Z")

</div>

I have permission to update the cookbook but this error is coming even  
listing the nodes.

C:\Users\dharmesh.patel\chef-repo\chef-repo\trunk\>knife node list  
ERROR: You have an error in your config file  
C:/Users/dharmesh.patel/chef-repo/c  
hef-repo/trunk/.chef/knife.rb  
TypeError: can’t convert nil into String  
C:/Users/dharmesh.patel/chef-repo/chef-repo/trunk/.chef/knife.rb:3:in  
`initial ize' C:/Users/dharmesh.patel/chef-repo/chef-repo/trunk/.chef/knife.rb:3:in`open’  
C:/Users/dharmesh.patel/chef-repo/chef-repo/trunk/.chef/knife.rb:3:in  
`from\_st  
ring’

```
 # C:/Users/dharmesh.patel/chef-repo/chef-repo/trunk/.chef/knife.rb

```

2:  
3: config = YAML::load(File.open(ENV[“CHEF\_CONFIG”]))  
4: provider = ENV[‘CHEF\_PROVIDER’] || “internal”

–  
Thanks & Regards

Dharmesh Patel

---

<div class="post-metadata">

**Author:** ![werebus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/werebus/32/24_2.png) [@werebus](https://discourse.chef.io/u/werebus)\
**Post date:** [December 24, 2014, 7:12pm UTC](https://discourse.chef.io/t/getting-this-error-when-using-knife-command/6115/2 "2014-12-24T19:12:53Z")

</div>

It looks like the author of your knife.rb file expected the environment  
variable, “CHEF\_CONFIG“, to exist and it doesn’t. That is,  
ENV["CHEF\_CONFIG"] is returning nil which in turn can’t be used as a file  
name to open.

I’m guessing here, but it looks like the intention was for that environment  
variable to contain the path to a YAML file that has some configuration in  
it? This isn’t a default behavior, as far as I know. Perhaps your  
organization has some documentation to refer to?

Sadly, my Windows knowledge is pretty poor; I might be missing something.

Matt Moretti  
​

On Wed, Dec 24, 2014 at 11:44 AM, dharmesh patel \<[dharmeshradadiya@gmail.com](mailto:dharmeshradadiya@gmail.com)

> wrote:

> I have permission to update the cookbook but this error is coming even  
> listing the nodes.
> 
> C:\Users\dharmesh.patel\chef-repo\chef-repo\trunk\>knife node list  
> ERROR: You have an error in your config file  
> C:/Users/dharmesh.patel/chef-repo/c  
> hef-repo/trunk/.chef/knife.rb  
> TypeError: can't convert nil into String  
> C:/Users/dharmesh.patel/chef-repo/chef-repo/trunk/.chef/knife.rb:3:in  
> `initial ize' C:/Users/dharmesh.patel/chef-repo/chef-repo/trunk/.chef/knife.rb:3:in `open'  
> C:/Users/dharmesh.patel/chef-repo/chef-repo/trunk/.chef/knife.rb:3:in  
> `from\_st  
> ring'
> 
> ```
> # C:/Users/dharmesh.patel/chef-repo/chef-repo/trunk/.chef/knife.rb
> 
> ```
> 
> 2:  
> 3: config = YAML::load(File.open(ENV["CHEF\_CONFIG"]))  
> 4: provider = ENV['CHEF\_PROVIDER'] || "internal"
> 
> --  
> Thanks & Regards
> 
> Dharmesh Patel

---

<div class="post-metadata">

**Author:** ![dharmesh\_patel](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@dharmesh\_patel](https://discourse.chef.io/u/dharmesh_patel)\
**Post date:** [December 24, 2014, 10:16pm UTC](https://discourse.chef.io/t/getting-this-error-when-using-knife-command/6115/3 "2014-12-24T22:16:19Z")

</div>

Thanks Matt.

Environment variable was messed up in my windows machine. I did fixed this  
issue. It is working as expected.

On Wed, Dec 24, 2014 at 12:12 PM, Matthew Moretti [werebus@gmail.com](mailto:werebus@gmail.com) wrote:

> It looks like the author of your knife.rb file expected the environment  
> variable, “CHEF\_CONFIG“, to exist and it doesn’t. That is,  
> ENV["CHEF\_CONFIG"] is returning nil which in turn can’t be used as a file  
> name to open.
> 
> I’m guessing here, but it looks like the intention was for that  
> environment variable to contain the path to a YAML file that has some  
> configuration in it? This isn’t a default behavior, as far as I know.  
> Perhaps your organization has some documentation to refer to?
> 
> Sadly, my Windows knowledge is pretty poor; I might be missing something.
> 
> Matt Moretti  
> ​
> 
> On Wed, Dec 24, 2014 at 11:44 AM, dharmesh patel \<  
> [dharmeshradadiya@gmail.com](mailto:dharmeshradadiya@gmail.com)\> wrote:
> 
> > I have permission to update the cookbook but this error is coming even  
> > listing the nodes.
> > 
> > C:\Users\dharmesh.patel\chef-repo\chef-repo\trunk\>knife node list  
> > ERROR: You have an error in your config file  
> > C:/Users/dharmesh.patel/chef-repo/c  
> > hef-repo/trunk/.chef/knife.rb  
> > TypeError: can't convert nil into String  
> > C:/Users/dharmesh.patel/chef-repo/chef-repo/trunk/.chef/knife.rb:3:in  
> > `initial ize' C:/Users/dharmesh.patel/chef-repo/chef-repo/trunk/.chef/knife.rb:3:in `open'  
> > C:/Users/dharmesh.patel/chef-repo/chef-repo/trunk/.chef/knife.rb:3:in  
> > `from\_st  
> > ring'
> > 
> > ```
> > # C:/Users/dharmesh.patel/chef-repo/chef-repo/trunk/.chef/knife.rb
> > 
> > ```
> > 
> > 2:  
> > 3: config = YAML::load(File.open(ENV["CHEF\_CONFIG"]))  
> > 4: provider = ENV['CHEF\_PROVIDER'] || "internal"
> > 
> > --  
> > Thanks & Regards
> > 
> > Dharmesh Patel

--  
Thanks & Regards

Dharmesh Patel (B.E.I.T)
