| Originally reported as part of PUP-10080: puppet fails if its working directory does not exist. Josh Cooper attributes the failure to Facter, and indeed, the standalone facter executable seems to exhibit related behavior. All puppet faces seem to be affected, including those that have no plausible need for working-directory access, such as puppet help. Facter does not exhibit such a failure when the working directory exists but is inaccessible to it. Expected behavior When its working directory does not exist, facter should nevertheless run successfully and evaluate and report all the facts it can do. This should happen for both the standalone executable and for the Puppet-integrated version. Observed behavior Facter crashes immediately when its working directory does not exist. For the puppet-integrated version, this crashes the whole puppet process. To reproduce 1. Create a fresh directory for the experiment: mkdir doomed. 2. Make that directory the working directory: cd doomed. 3. In a separate shell, remove the directory: rm doomed. 4. In the first shell, run facter or any Puppet command at all, for example
or
or even
The Puppet output under these circumstances is
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory terminate called after throwing an instance of 'boost::filesystem::filesystem_error' what(): boost::filesystem::current_path: No such file or directory Aborted
The output of the standalone facter executable is similar:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory 2019-10-03 13:35:14.747025 FATAL puppetlabs.facter - unhandled exception: boost::filesystem::current_path: No such file or directory
Of course, the natural workaround is to run puppet and / or facter from an existing working directory. Doing otherwise unintentionally is unlikely in typical environments. |