[PDK-1204] The bundled version of puppet-lint fails when not called from the root of the repository Created: 2018/10/18  Updated: 2019/01/24  Resolved: 2018/12/10

Status: Resolved
Project: Puppet Development Kit
Component/s: None
Affects Version/s: None
Fix Version/s: PDK 1.9.0

Type: Bug Priority: Normal
Reporter: Rob Nelson Assignee: Tim Sharpe
Resolution: Fixed Votes: 0
Labels: resolved-issue-added
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Method Found: Needs Assessment
Release Notes: Bug Fix
Release Notes Summary: Fixes a bug in PDK where file targets were not evaluated based on the current working directory. This caused `pdk validate <target>` to fail when run from a module's subdirectory.
QA Risk Assessment: Needs Assessment

 Description   

When calling `pdk bundle exec puppet-lint $file` from the root of a repository, it works fine.

[rnelson0@build03 domain_join:master]$ puppet-lint manifests/init.pp
[rnelson0@build03 domain_join:master]$ pdk bundle exec puppet-lint manifests/init.pp
pdk (INFO): Using Ruby 2.5.1
pdk (INFO): Using Puppet 6.0.2

When called from any other directory but still in the repo, it fails with "no file specified or specified file does not exist"

[rnelson0@build03 domain_join:master]$ cd manifests/
[rnelson0@build03 manifests:master]$ puppet-lint init.pp
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 14) on line 48
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 14) on line 52
WARNING: indentation of => is not properly aligned (expected in column 17, but found it in column 16) on line 57
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 14) on line 65
WARNING: indentation of => is not properly aligned (expected in column 13, but found it in column 12) on line 73
WARNING: indentation of => is not properly aligned (expected in column 13, but found it in column 10) on line 75
[rnelson0@build03 manifests:master]$ pdk bundle exec puppet-lint init.pp
pdk (INFO): Using Ruby 2.5.1
pdk (INFO): Using Puppet 6.0.2
puppet-lint: no file specified or specified file does not exist
puppet-lint: try 'puppet-lint --help' for more information[rnelson0@build03 manifests:master]$ cd ../spec
[rnelson0@build03 spec:master]$ puppet-lint ../manifests/init.pp
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 14) on line 48
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 14) on line 52
WARNING: indentation of => is not properly aligned (expected in column 17, but found it in column 16) on line 57
WARNING: indentation of => is not properly aligned (expected in column 15, but found it in column 14) on line 65
WARNING: indentation of => is not properly aligned (expected in column 13, but found it in column 12) on line 73
WARNING: indentation of => is not properly aligned (expected in column 13, but found it in column 10) on line 75
[rnelson0@build03 spec:master]$ pdk bundle exec puppet-lint ../manifests/init.pp
pdk (INFO): Using Ruby 2.5.1
pdk (INFO): Using Puppet 6.0.2
puppet-lint: no file specified or specified file does not exist
puppet-lint: try 'puppet-lint --help' for more information 

What's weird is that the error message is ONLY from a PuppetLint::NoCodeError exception, which best I can tell is only triggered when `@code.nil?`. SeeĀ here and here. That appears to get set to nil in initialize/new, then pretty quickly get set in file=, then crash out in run ([here|https://github.com/rodjek/puppet-lint/blob/3c379cfe101d0e1705797c0191ab0194c66ef71b/lib/puppet-lint/bin.rb#L64-L66).] I'm not sure how the file= could fail since the path exists, unless the pdk is gobbling up the path somehow.



 Comments   
Comment by Bryan Jen [ 2018/10/31 ]

Need to modify the PDK code to use the current working directory instead of forcing module-root.

Generated at Fri Oct 18 02:34:42 PDT 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.