[chef-dev] Re: error in json_compat when doing a cookbook upload


Chronological Thread 
  • From: Daniel DeLeo < >
  • To: Kishore S Kumar < >
  • Cc: chef-dev < >
  • Subject: [chef-dev] Re: error in json_compat when doing a cookbook upload
  • Date: Tue, 4 Dec 2012 09:03:40 -0800


On Tuesday, December 4, 2012 at 3:21 AM, Kishore S Kumar wrote:

does anyone get this error while doing a `knife cookbook upload ..`

1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:43:in `rescue in block in deep_const_get': can't get const Chef::Sandbox: uninitialized constant Chef::Sandbox (ArgumentError)
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:40:in `block in deep_const_get'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:35:in `each'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:35:in `inject'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:35:in `deep_const_get'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:148:in `parse'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:148:in `parse'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/json_compat.rb:41:in `from_json'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/rest.rb:217:in `block in raw_http_request'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/rest.rb:317:in `retriable_rest_request'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/rest.rb:201:in `raw_http_request'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/rest.rb:195:in `api_request'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/rest.rb:162:in `put'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/cookbook_uploader.rb:99:in `upload_cookbooks'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/knife/cookbook_upload.rb:230:in `upload'

making the following changes in rest.rb (line 217) fixed it.
if response['content-type'] =~ /json/
  Chef::JSONCompat.from_json(response_body.chomp, create_additions: false)
else

but I'm wondering if there is something else that I should be doing than this fix..

Looks like you're building from master? We recently fixed this, so try pulling and rebuilding the gem.

Chef unfortunately still relies on magical class inflation via json_class in quite a few places, so setting create_additions to false would break things elsewhere. We ended up fixing this particular issue by adding a dummy Sandbox class, which was the least ugly solution. Getting rid of json_class is something we'd like to do but just haven't had time for yet.

-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§