chef / chef-apply

The ad-hoc execution tool for the Chef ecosystem.
https://www.chef.sh/
Apache License 2.0
14 stars 14 forks source link

Can't have local copy of cookbook that is also in supermarket. #10

Open jamesc opened 6 years ago

jamesc commented 6 years ago

have a directory with 2 cookbooks, 1 in supermarket, the other not but with a dependency on first e.g.

demo
 - hab_national_parks
 - habitat   # This is also in supermarket

Berksfile in hab_national_parks points to ../habitat.

now I do a chef-run hab_national_parks.

Expected: It should use the version in the current directory

Actual:

[\] Generating local policyfile...

CHEFPOLICY001

Could not create local Policyfile bundle.

The following error was reported:

  Failed to generate Policyfile.lock

If you are not able to resolve this issue, please contact Chef support
at beta@chef.io and include the log file and stack trace from the
locations below:

  /home/james/.chef-workstation/logs/default.log
  /home/james/.chef-workstation/logs/stack-trace.log

Stack trace says:

ChefApply::CLI::PolicyfileInstallError: ChefApply::CLI::PolicyfileInstallError
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-apply-0.1.0/lib/chef_apply/cli.rb:292:in `rescue in create_local_policy'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-apply-0.1.0/lib/chef_apply/cli.rb:289:in `create_local_policy'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-apply-0.1.0/lib/chef_apply/cli.rb:108:in `block in perform_run'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-apply-0.1.0/lib/chef_apply/ui/terminal.rb:83:in `block in render_job'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/tty-spinner-0.8.0/lib/tty/spinner.rb:208:in `instance_eval'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/tty-spinner-0.8.0/lib/tty/spinner.rb:208:in `execute_job'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/tty-spinner-0.8.0/lib/tty/spinner.rb:290:in `block in run'
Caused by: ChefDK::PolicyfileInstallError: Failed to generate Policyfile.lock
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.1.0/lib/chef-dk/policyfile_services/install.rb:113:in `rescue in generate_lock_and_install'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.1.0/lib/chef-dk/policyfile_services/install.rb:92:in `generate_lock_and_install'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.1.0/lib/chef-dk/policyfile_services/install.rb:62:in `run'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-apply-0.1.0/lib/chef_apply/cli.rb:290:in `create_local_policy'
        ... 5 more
Caused by: ChefDK::CookbookSourceConflict: Source chef_repo(/mnt/c/src/github/jamesc/demo) and supermarket(https://supermarket.chef.io) contain conflicting cookbooks:
- habitat

You can set a preferred source to resolve this issue with code like:

default_source :chef_repo, "/mnt/c/src/github/jamesc/demo" do |s|
  s.preferred_for "habitat"
end
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.1.0/lib/chef-dk/policyfile_compiler.rb:414:in `handle_conflicting_cookbooks'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.1.0/lib/chef-dk/policyfile_compiler.rb:302:in `remote_artifacts_graph'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.1.0/lib/chef-dk/policyfile_compiler.rb:266:in `artifacts_graph'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.1.0/lib/chef-dk/policyfile_compiler.rb:234:in `block in graph'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.1.0/lib/chef-dk/policyfile_compiler.rb:233:in `tap'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.1.0/lib/chef-dk/policyfile_compiler.rb:233:in `graph'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.1.0/lib/chef-dk/policyfile_compiler.rb:229:in `graph_solution'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.1.0/lib/chef-dk/policyfile_compiler.rb:176:in `install'
        /opt/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.1.0/lib/chef-dk/policyfile_services/install.rb:100:in `generate_lock_and_install'
        ... 7 more
cheeseplus commented 6 years ago

Looking at this one and I feel like the code is still probably doing the right thing by blowing up. I think we can perhaps look at the Policyfile.rb we generate and see if we can automatically take care of the below error suggestion

You can set a preferred source to resolve this issue with code like:

default_source :chef_repo, "/mnt/c/src/github/jamesc/demo" do |s|
  s.preferred_for "habitat"
end
tyler-ball commented 5 years ago

Triaging all existing issues. I think the right answer for this issue now is to 'unroll' that underlying error. The message in that error gives the user actions they can take, so we should display that to them on the command line rather than forcing them to hunt in a log file for it.