chef-boneyard / chef-provisioning

A library for creating machines and infrastructures idempotently in Chef.
Apache License 2.0
524 stars 164 forks source link

Encoding Errors - reason: /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:155:in `encode': "\xE2" on US-ASCII (Encoding::InvalidByteSequenceError) #190

Open kplimack opened 9 years ago

kplimack commented 9 years ago
─jplimack@Jake.local ~/chef/cookbooks/chef-metal101  ‹master*›
╰─➤  chef-client -z recipes/{vagrant_linux.rb,simple.rb}  2>&1
Starting Chef Client, version 11.14.0.rc.2
resolving cookbooks for run list: []
[2014-10-09T11:38:38-06:00] WARN: Cookbook 'virtualbox' is empty or entirely chefignored at /Users/jakeplimack/chef/cookbooks/virtualbox
Synchronizing Cookbooks:
Compiling Cookbooks...
WARN: Unresolved specs during Gem::Specification.reset:
      nokogiri (>= 1.4.0, ~> 1.5)
      uuidtools (~> 2.1.2)
      gyoku (>= 0.4.0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
[2014-10-09T11:38:39-06:00] WARN: Node Jake.local has an empty run list.
Converging 2 resources
Recipe: @recipe_files::/Users/jakeplimack/chef/cookbooks/chef-metal101/recipes/vagrant_linux.rb
  * vagrant_box[precise64] action create (up to date)
Recipe: @recipe_files::/Users/jakeplimack/chef/cookbooks/chef-metal101/recipes/simple.rb
  * machine[mario] action converge

    ================================================================================
    Error executing action `converge` on resource 'machine[mario]'
    ================================================================================

    RuntimeError
    ------------
    vagrant up mario failed!
    STDOUT:Bringing machine 'mario' up with 'virtualbox' provider...
    ==> mario: The cookbook path '/Users/jakeplimack/.berkshelf/mario/vagrant/berkshelf-20141009-47885-1fy02ek-mario' doesn't exist. Ignoring...
    Updating Vagrant's berkshelf: '/Users/jakeplimack/.berkshelf/mario/vagrant/berkshelf-20141009-47885-1fy02ek-mario'

    STDERR:Berkshelf::BerksError: Berks command Failed: /opt/chefdk/bin/berks vendor /Users/jakeplimack/.berkshelf/mario/vagrant/berkshelf-20141009-47885-1fy02ek-mario --berksfile=/Users/jakeplimack/chef/cookbooks/chef-metal101/.chef/vms/Berksfile, reason: /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:155:in `encode': "\xE2" on US-ASCII (Encoding::InvalidByteSequenceError)
        from /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:155:in `initialize'
        from /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:155:in `new'
        from /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:155:in `parse'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.0.0/lib/ridley/chef/cookbook/metadata.rb:458:in `from_json'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.0.0/lib/ridley/chef/cookbook/metadata.rb:29:in `from_json'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.0.0/lib/ridley/chef/cookbook.rb:36:in `from_path'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cached_cookbook.rb:15:in `from_store_path'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cookbook_store.rb:108:in `block in cookbooks'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cookbook_store.rb:98:in `collect'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cookbook_store.rb:98:in `cookbooks'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/resolver/graph.rb:8:in `populate_store'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/resolver.rb:73:in `resolve'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/installer.rb:174:in `install_from_universe'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/installer.rb:39:in `run'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:371:in `install'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:590:in `vendor'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:387:in `vendor'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:52:in `dispatch'
        from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:27:in `execute!'
        from /opt/chefdk/embedded/apps/berkshelf/bin/berks:5:in `<top (required)>'
        from /opt/chefdk/bin/berks:37:in `load'
        from /opt/chefdk/bin/berks:37:in `<main>'

    Resource Declaration:
    ---------------------
    # In /Users/jakeplimack/chef/cookbooks/chef-metal101/recipes/simple.rb

      3: machine 'mario' do
      4:   tag 'itsa_me'
      5:   converge true
      6: end

    Compiled Resource:
    ------------------
    # Declared in /Users/jakeplimack/chef/cookbooks/chef-metal101/recipes/simple.rb:3:in `from_file'

    machine("mario") do
      action :converge
      retries 0
      retry_delay 2
      guard_interpreter :default
      chef_server {:chef_server_url=>"http://127.0.0.1:8889", :options=>{:client_name=>"Jake.local", :signing_key_filename=>nil}}
      driver "vagrant"
      machine_options {:vagrant_options=>{"vm.box"=>"precise64"}}
      cookbook_name "@recipe_files"
      recipe_name "/Users/jakeplimack/chef/cookbooks/chef-metal101/recipes/simple.rb"
      attribute_modifiers [["tags", #<Proc:0x007f816a934480@/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/cheffish-0.8.3/lib/cheffish.rb:149>]]
      converge true
    end

Running handlers:
[2014-10-09T11:39:03-06:00] ERROR: Running exception handlers
Running handlers complete
[2014-10-09T11:39:03-06:00] ERROR: Exception handlers complete
[2014-10-09T11:39:03-06:00] FATAL: Stacktrace dumped to /Users/jakeplimack/chef/cookbooks/chef-metal101/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 31.484598 seconds
[2014-10-09T11:39:03-06:00] ERROR: machine[mario] (@recipe_files::/Users/jakeplimack/chef/cookbooks/chef-metal101/recipes/simple.rb line 3) had an error: RuntimeError: vagrant up mario failed!
STDOUT:Bringing machine 'mario' up with 'virtualbox' provider...
==> mario: The cookbook path '/Users/jakeplimack/.berkshelf/mario/vagrant/berkshelf-20141009-47885-1fy02ek-mario' doesn't exist. Ignoring...
Updating Vagrant's berkshelf: '/Users/jakeplimack/.berkshelf/mario/vagrant/berkshelf-20141009-47885-1fy02ek-mario'

STDERR:Berkshelf::BerksError: Berks command Failed: /opt/chefdk/bin/berks vendor /Users/jakeplimack/.berkshelf/mario/vagrant/berkshelf-20141009-47885-1fy02ek-mario --berksfile=/Users/jakeplimack/chef/cookbooks/chef-metal101/.chef/vms/Berksfile, reason: /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:155:in `encode': "\xE2" on US-ASCII (Encoding::InvalidByteSequenceError)
    from /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:155:in `initialize'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:155:in `new'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:155:in `parse'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.0.0/lib/ridley/chef/cookbook/metadata.rb:458:in `from_json'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.0.0/lib/ridley/chef/cookbook/metadata.rb:29:in `from_json'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.0.0/lib/ridley/chef/cookbook.rb:36:in `from_path'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cached_cookbook.rb:15:in `from_store_path'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cookbook_store.rb:108:in `block in cookbooks'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cookbook_store.rb:98:in `collect'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cookbook_store.rb:98:in `cookbooks'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/resolver/graph.rb:8:in `populate_store'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/resolver.rb:73:in `resolve'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/installer.rb:174:in `install_from_universe'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/installer.rb:39:in `run'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:371:in `install'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:590:in `vendor'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:387:in `vendor'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:52:in `dispatch'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:27:in `execute!'
    from /opt/chefdk/embedded/apps/berkshelf/bin/berks:5:in `<top (required)>'
    from /opt/chefdk/bin/berks:37:in `load'
    from /opt/chefdk/bin/berks:37:in `<main>'

[2014-10-09T11:39:03-06:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
sstarcher commented 9 years ago

I have received a similar error when using a Grafana cookbook Vendoring grafana (1.5.1) to /var/chef/cookbooks/grafana /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:254:in encode': "\xC3" on US-ASCII (Encoding::InvalidByteSequenceError) from /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:254:ingenerate' from /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:254:in fast_generate' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.0.0/lib/ridley/chef/cookbook/metadata.rb:433:into_json' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.0.0/lib/ridley/chef/cookbook.rb:123:in block in compile_metadata' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.0.0/lib/ridley/chef/cookbook.rb:122:inopen' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.0.0/lib/ridley/chef/cookbook.rb:122:in compile_metadata' from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:607:inblock in vendor' from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:594:in each' from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:594:invendor' from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:387:in vendor' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:inrun' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in invoke_command' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:indispatch' from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:52:in dispatch' from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:instart' from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/cli.rb:27:in execute!' from /opt/chefdk/embedded/apps/berkshelf/bin/berks:5:in<top (required)>' from /opt/chefdk/bin/berks:37:in load' from /opt/chefdk/bin/berks:37:in

'

jkeiser commented 9 years ago

@kplimack this looks issueful: does this directory in fact exist?

mario: The cookbook path '/Users/jakeplimack/.berkshelf/mario/vagrant/berkshelf-20141009-47885-1fy02ek-mario' doesn't exist. Ignoring...
noslowerdna commented 9 years ago

I ran into the same problem with berks vendor for vagrant for one of our cookbooks.

Stack trace:

    stderr: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0/lib/celluloid/cpu_counter.rb:28: warning: Insecure world writable dir /usr/local in PATH, mode 040777
/opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:254:in `encode': "\xE2" on US-ASCII (Encoding::InvalidByteSequenceError)
    from /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:254:in `generate'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/json/common.rb:254:in `fast_generate'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.1.0/lib/ridley/chef/cookbook/metadata.rb:433:in `to_json'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.1.0/lib/ridley/chef/cookbook.rb:123:in `block in compile_metadata'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.1.0/lib/ridley/chef/cookbook.rb:122:in `open'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.1.0/lib/ridley/chef/cookbook.rb:122:in `compile_metadata'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:596:in `block (2 levels) in vendor'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:583:in `each'
    from /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb:583:in `block in vendor'

Found a workaround from https://github.com/cucumber/gherkin/issues/192 - setting this environment variable prior to vagrant up resolved it for me.

export LANG=en_US.UTF-8

(previously had LANG=C set as a workaround for a different problem)

JonathanRamier commented 9 years ago

+1 export LANG=en_US.UTF-8 works for me

jkeiser commented 9 years ago

Digging deeper, it looks like Berkshelf has this problem in more than one place: https://github.com/berkshelf/berkshelf-api/issues/112

jkeiser commented 9 years ago

I'll try and track that down, but I suspect users are going to need to ensure their systems are set to LANG=en_US.UTF-8 (or SOMETHING.UTF-8) until we know what's going on. I don't think this will make chef-provisioning 1.0 (though I could be wrong).