chef-boneyard/chef-dk

chef install fails when include_policy with git target is used

AndrzejBaldys opened this issue · 2 comments

Description

I've tried to create a policyfile for project composed from non project specific policyfiles.
When I'm including policyfiles from local path all works well. When I'm trying to include them from remote git repo I'm getting error msg:

"Error: Failed to generate Policyfile.lock
Reason: (NoMethodError) undefined method 'to_wide_string' for #<Pathname:0x00000000053d8bc8>"

I've start to debugging that and it seems that in core_ext.rb:235 object of class Pathname is provided instead of String.

Pathname object provided: #<Pathname:C:/Users/USER_NAME/AppData/Local/chefdk/cache/.cache/git/07fdd6a887f6045af4323ec885efde24abad84f2>

That explain why NoMethodError appeared but I have no idea why or how Pathname object gets there in the first place.

ChefDK Version

Chef Development Kit Version: 3.3.23
chef-client version: 14.5.33
delivery version: master (6862f27aba89109a9630f0b6c6798efec56b4efe)
berks version: 7.0.6
kitchen version: 1.23.2
inspec version: 2.2.112
ruby 2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32]

Platform Version

Windows 10 Enterprise Version 1803 (OS Build 17134.345)

Replication Case

  1. Run chef generate cookbook -P
  2. Fill Policyfile.rb with:
    name 'PROJECT_NAME'
    run_list 'PROJECT_NAME::default'
    cookbook 'PROJECT_NAME', path : '.'
    include_policy 'POLICY_NAME', git: 'https://COMPANY_NAME/gitlab/Cookbooks/PROJECT_NAME.git, branch: 'BRANCH_NAME', path: 'path/to/Policyfile.lock.json
  1. Run chef install

Stacktrace

PS C:\chef\cookbooks\PROJECT_NAME> chef install --debug
Building policy PROJECT_NAME
Error: Failed to generate Policyfile.lock
Reason: (NoMethodError) undefined method `to_wide_string' for #<Pathname:0x0000000004140f60>

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0-universal-mingw32/lib/mixlib/shellout/windows/core_ext.rb:235:in `create'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0-universal-mingw32/lib/mixlib/shellout/windows.rb:91:in `run_command'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0-universal-mingw32/lib/mixlib/shellout.rb:267:in `run_command'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/policyfile/git_lock_fetcher.rb:234:in `git'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/policyfile/git_lock_fetcher.rb:198:in `show_file'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/policyfile/git_lock_fetcher.rb:156:in `fetch_lock_data'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/policyfile/git_lock_fetcher.rb:106:in `lock_data'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/policyfile/policyfile_location_specification.rb:107:in `policyfile_lock'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/policyfile_compiler.rb:100:in `block in expanded_run_list'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/policyfile_compiler.rb:99:in `each'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/policyfile_compiler.rb:99:in `expanded_run_list'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/policyfile_services/install.rb:78:in `expanded_run_list'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/policyfile_services/install.rb:97:in `generate_lock_and_install'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/policyfile_services/install.rb:63:in `run'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/command/install.rb:78:in `run'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/command/base.rb:58:in `run_with_default_options'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/lib/chef-dk/cli.rb:73:in `run'

C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.3.23/bin/chef:25:in `<top (required)>'

C:/opscode/chefdk/bin/chef:307:in `load'

C:/opscode/chefdk/bin/chef:307:in `\<main\>'

This is fixed in the latest version of Chef Workstation and ChefDK is being deprecated next year. Can you install Chef Workstation and ensure that fixes this error for you? If it does not please re-open this and we will get it fixed. Thank you!

lock commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.