Every time get a "warning: already initialized constant"

Each time when i run any command like "knife cookbook ..." or "knife show ..." I see bunch of alerts:

/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:31: warning: already initialized constant Chef::Knife::Bootstrap::SUPPORTED_CONNECTION_PROTOCOLS
/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:31: warning: previous definition of SUPPORTED_CONNECTION_PROTOCOLS was here
/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:32: warning: already initialized constant Chef::Knife::Bootstrap::WINRM_AUTH_PROTOCOL_LIST
/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:32: warning: previous definition of WINRM_AUTH_PROTOCOL_LIST was here
/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:350: warning: already initialized constant Chef::Knife::Bootstrap::DEPRECATED_FLAGS
/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:350: warning: previous definition of DEPRECATED_FLAGS was here

How i can avoid this? Is it normal behaviour?

OS: MacOS 10.14.5

Hey,

unfortunetly had the same issue while using: 4.0.60 at CentOS Linux release 7.6.1810.
It was not only causing this problem, also wasnt able to execute knife bootstrap, below attaching logs.
Simply downgrading to: chefdk-3.10.1 solved this problem :confused: Would like to use newer version tho, looking for some feedback from authors.

knife bootstrap X.X.X.X --ssh-user root --run-list 'recipe[access]'
/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:31: warning: already initialized constant Chef::Knife::Bootstrap::SUPPORTED_CONNECTION_PROTOCOLS
/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:31: warning: previous definition of SUPPORTED_CONNECTION_PROTOCOLS was here
/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:32: warning: already initialized constant Chef::Knife::Bootstrap::WINRM_AUTH_PROTOCOL_LIST
/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:32: warning: previous definition of WINRM_AUTH_PROTOCOL_LIST was here
/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:350: warning: already initialized constant Chef::Knife::Bootstrap::DEPRECATED_FLAGS
/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:350: warning: previous definition of DEPRECATED_FLAGS was here
WARNING: You provided --ssh-user. This flag is deprecated. Please use '--connection-user USERNAME' instead.
Performing legacy client registration with the validation key at MYKEY.pem...
Delete your validation key in order to use your user credentials for client registration instead.
Connecting to X.X.X.X
WARN: [SSH] PTY requested: stderr will be merged into stdout
The authenticity of host 'X.X.X.X ()' can't be established.
Are you sure you want to continue connecting
(Y/N) Y
WARN: [SSH] PTY requested: stderr will be merged into stdout
ERROR: Errno::ENOENT: No such file or directory @ rb_sysopen - /tmp/d20190603-19981-1r3540c/.pem

same here

That's a harmless warning that can be ignored. We'll get that resolved for the next release, but there's no need to downgrade over the warning.

-Timi

1 Like

tas50 - as chefuser90 mentioned, he didn't downgrade only over the warning itself but because he was unable to run bootstrap, as you can see in logs that he attached:

ERROR: Errno::ENOENT: No such file or directory @ rb_sysopen - /tmp/d20190603-19981-1r3540c/.pem

It is suspicious that downgrading resolved both warning and unability to bootstrap a node. It seems that there is a problem with latest ChefDK.

The annoying warnings can be ignore, yes. But unable to bootstrap can't go unnoticed. Need an immediate fix on this. Or I'm alone?

I think above someone wrote that not only warnings was a problem. For me all functions are work fine, but warnings annoying.

I've found another nasty issue in ChefDK 4.0.60 - it is incompatible with the old version in rest API implementation. Code
out = @rest.get("#{jreq}/output/#{@node}/stdout", headers = { Accept: 'application/octet-stream' })
works with ChefDK 3, but with version 4 I've got an error:
Traceback (most recent call last):
3: from ./job_run.rb:77:in <main>' 2: from /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/http.rb:115:inget'
1: from /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/http.rb:152:in request' /opt/chefdk/embedded/lib/ruby/2.6.0/net/http/response.rb:122:inerror!': 406 "Not Acceptable" (Net::HTTPServerException)
4: from ./job_run.rb:77:in <main>' 3: from /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/http.rb:115:inget'
2: from /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/http.rb:144:in request' 1: from /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/http.rb:158:inrescue in request'
/opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.300/lib/chef/http.rb:456:in version_retries': undefined methodpossible_requests' for nil:NilClass (NoMethodError)

To make it working with ChefDK 4 it needs to be changed to:
out = @rest.get("#{jreq}/output/#{@node}/stdout", headers = { 'Accept' => 'application/octet-stream' })