[PDK-446] pdk is not on path in all contexts Created: 2017/08/24  Updated: 2017/10/31  Resolved: 2017/09/04

Status: Closed
Project: Puppet Development Kit
Component/s: None
Affects Version/s: PDK 1.0.0, PDK 1.0.1
Fix Version/s: PDK 1.1.0

Type: Bug Priority: Major
Reporter: David Schmitt Assignee: James Stocks
Resolution: Fixed Votes: 0
Labels: known-issue-added, resolved-issue-added
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Acceptance Criteria:
  • package testing passes in CI with the test helper code to use the full path to PDK removed
  • PDK binary moved from /opt/puppetlabs/bin to /opt/puppetlabs/pdk/bin
    • Automatically handle or document upgrading from PDK 1.0
  • pdk using zsh on OSX confirmed to have no specific issues (this ticket originally reported as a zsh specific issue)
Epic Link: PDK v1.1
Team: Puppet Developer Experience
Release Notes: Bug Fix
Release Notes Summary: Resolved issue:

PDK was not automatically added to the PATH in some shells, including zsh on Mac OS X and Debian. This issue is now resolved on our supported OSes.

Known issue:

### PDK not in shell PATH

PDK is not automatically added to the PATH in some shells. To fix this, add the PATH to the affected shells:

* For zsh on OS X, add the PATH by adding the line `eval '/usr/libexec/path_helper -s'` to to the zsh resource file (`~/.zshrc`).

* For Debian, add a symlink to `/usr/local/bin` by running `sudo ln -sv /opt/puppetlabs/bin/pdk /usr/local/bin/`
QA Risk Assessment: Needs Assessment


Package testing on OSX currently passes only due to using the full path to pdk ( https://github.com/puppetlabs/pdk/blob/master/package-testing/lib/pdk/pdk_helper.rb#L18 )
If the full path is not used, package testing fails:

Errored Tests Cases:
  Test Case tests/validate_a_new_module.rb reported: #<Beaker::Host::CommandFailure: Host 'pttvlhrt1eevpju.delivery.puppetlabs.net' exited with 127 running:
 pdk new module c100321_module --skip-interview
Last 10 lines of output were:
        sh: pdk: command not found>
    Test line: tests/validate_a_new_module.rb:11:in `block (3 levels) in run_test'

Comment by Thomas Honey [ 2017/08/24 ]

specifically i added to the ~/.zshrc file. I put this at the end


Comment by James Stocks [ 2017/08/24 ]

Package testing works on redhat 7 without needing the full path; so this does appear to only affect OSX

Comment by Austin Blatt [ 2017/08/24 ]

Since this works automagically for Bash, and not for zsh, should the path_helper sourcing be documented as a "if you're using a non-Bash shell on OSX you'll need to..."?

Comment by Jean Bond [ 2017/08/24 ]

Austin Blatt for that wording, I'd want to know that it broke on non-bash shells other than zsh.

Comment by Jean Bond [ 2017/08/24 ]

Bryan Jen] or Austin Blatt, can you look over the note on the docs tab and let me know if it looks ok? I want to get this on the known issues page.

Comment by David Schmitt [ 2017/08/25 ]

For the record, there is also something fishy going on with PATH manipulation on Debian. See https://github.com/puppetlabs/pdk/issues/272 for details.

Given that this is now 2 out of the three big posix platforms not working very well, I'm upgrading this, and push it up to a v1.1 issue.

Comment by James Stocks [ 2017/08/25 ]

The behaviour on OSX appears as Jesse Scott suspected...

it's possible the path_helper stuff is not getting run for the type of shell that SSH is creating, I think it only runs on login shells by default

On a beaker test system (TEST_TARGET=osx1012-64workstation.); pdk is on the path when you log into the host; but is not on the path if the command is just sent via ssh like beaker does

jstocks@~$ ssh root@jegwph7vnb0kigz.delivery.puppetlabs.net pdk
sh: pdk: command not found
jstocks@~$ ssh root@jegwph7vnb0kigz.delivery.puppetlabs.net echo \$0
jstocks@~$ ssh root@jegwph7vnb0kigz.delivery.puppetlabs.net
Last login: Fri Aug 25 05:30:17 2017 from
jegwph7vnb0kigz:~ root# pdk
    pdk - Puppet Development Kit
    -h --help                     show help for this command
       --version                  show version of pdk
jegwph7vnb0kigz:~ root# echo $0
jegwph7vnb0kigz:~ root#

Comment by David Schmitt [ 2017/08/25 ]

augh. For testing against bash, a workaround could be using bash --login -c 'pdk ....' as command to execute, instead of plain pdk. That should go through the necessary motions to setup the environment correctly.

Comment by James Stocks [ 2017/08/25 ]

If I'm understanding this correctly then 3 things need addressed:

  • A tech note for OSX for anyone using zsh or a shell that does not source /etc/profile (Jean Bond I think the current note is good but can made consistent and helpful in more cases by telling zsh users to add `eval '/usr/libexec/path_helper -s'` to their ~/.zshrc file )
  • A packaging fix is needed for Debian as per comments on https://github.com/puppetlabs/pdk/issues/272
  • Lower priority, address the gap in beaker testing. Either have beaker itself work around limitations of not using a login shell; or leave beaker as-is and add an explicit beaker test to pdk that confirms pdk is on path when in a login shell
Comment by David Schmitt [ 2017/08/25 ]

Add 4) Check that on RedHat, logged in Gnome, the pdk is available on the PATH, and 5) file a ticket for the agent, as we copied their method of adding /opt/puppetlabs/bin to the path, probably followed quickly by 6) push the pdk binary back to /opt/puppetlabs/pdk/bin, and put THAT on all paths, to avoid the folks who do not want to have their production puppet on the path.

Comment by James Stocks [ 2017/08/29 ]

No issue on CentOS 7 with GNOME terminal

I believe puppet-agent does not put /opt/puppetlabs/bin on PATH intentionally; and we should move pdk back to /opt/puppetlabs/pdk/bin

Comment by Jean Bond [ 2017/08/29 ]

The known issue currently addresses Debian and zsh on OS X; if other specific workarounds come up while this work is happening, ping me and I can add them to the known issues.

Comment by James Stocks [ 2017/08/30 ]

Packaging PR here: https://github.com/puppetlabs/puppet-sdk-vanagon/pull/69
Also need to update the beaker test code in puppetlabs/pdk to meet the acceptance criteria for this ticket,

Comment by David Schmitt [ 2017/09/04 ]

Everything seems to be merged and green now.

Generated at Tue Jul 14 20:17:15 PDT 2020 using Jira 8.5.2#805002-sha1:a66f9354b9e12ac788984e5d84669c903a370049.