Skip to content

search_path: Add common elements from $PATH#138

Merged
bastelfreak merged 1 commit into
mainfrom
path
Jul 13, 2026
Merged

search_path: Add common elements from $PATH#138
bastelfreak merged 1 commit into
mainfrom
path

Conversation

@bastelfreak

@bastelfreak bastelfreak commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Previously, we only had to paths where we looked for binaries + $PATH. Those two paths were /sbin and /usr/sbin. This covers most binaries, but relying on $PATH is... unreliable. e.g. many people assume that /opt/puppetlabs/bin is available in search_paths. But this isn't guaranteed. It's added to $PATH by /etc/profile.d/puppet-agent.sh. So it's only available in interactive shells.

This causes the following bug:

https://github.com/voxpupuli/puppet-openvoxdb/blob/56261b7b5dda7211d610cf5b28b8356a7ab41b52/lib/facter/openvoxdb_version.rb#L5

When running puppet agent -t, this fact works and puppetdb is found at /opt/puppetlabs/bin/puppetdb. When running the puppet.service unit, /etc/profile.d/puppet-agent.sh isn't sourced so the fact is nil. And IMO this is a bug in OpenFact.

The whole list is still prefixed by $PATH.

Short description

Checklist

I have:

@bastelfreak bastelfreak self-assigned this Jul 12, 2026
@bastelfreak bastelfreak added the backwards-incompatible This change will lead to a major version bump for the next release label Jul 12, 2026
Comment thread lib/facter/custom_facts/core/execution/posix.rb Outdated
@bastelfreak bastelfreak force-pushed the path branch 2 times, most recently from 7270264 to 96388fa Compare July 12, 2026 10:51
Previously, we only had to paths where we looked for binaries + `$PATH`.
Those two paths were `/sbin` and `/usr/sbin`. This covers most binaries,
but relying on $PATH is... unreliable. e.g. many people assume that
`/opt/puppetlabs/bin` is available in `search_paths`. But this isn't
guaranteed. It's added to `$PATH` by `/etc/profile.d/puppet-agent.sh`.
So it's only available in interactive shells.

This causes the following bug:

https://github.com/voxpupuli/puppet-openvoxdb/blob/56261b7b5dda7211d610cf5b28b8356a7ab41b52/lib/facter/openvoxdb_version.rb#L5

When running `puppet agent -t`, this fact works and `puppetdb` is found
at `/opt/puppetlabs/bin/puppetdb`. When running the puppet.service unit,
`/etc/profile.d/puppet-agent.sh` isn't sourced so the fact is nil. And
IMO this is a bug in OpenFact.

The whole list is still prefixed by `$PATH`.

Signed-off-by: Tim Meusel <tim@bastelfreak.de>
@bastelfreak bastelfreak merged commit 4c4324f into main Jul 13, 2026
29 checks passed
@bastelfreak bastelfreak deleted the path branch July 13, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards-incompatible This change will lead to a major version bump for the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants