puppetlabs/puppet · error · FileReadError
Could not remove crontab for
Error message
Could not remove crontab for %{path}: %{detail} What it means
Raised as FileReadError by the SunOS (suntab) filetype's remove method (lib/puppet/util/filetype.rb:284) when executing 'crontab -r' for user %{path} fails. Unlike read, remove does not tolerate 'no crontab' or authorization messages — any failure from the crontab command is wrapped in this error with the command output in %{detail}.
Solutions
- Check %{detail} for the crontab -r failure reason (missing binary, permissions, no crontab present).
- Ensure the user %{path} exists and the invoking account may modify that user's crontab.
- If no crontab exists, make the removal idempotent in the caller before calling remove.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at lib/puppet/util/filetype.rb:284 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/dc62e074be5b1831.
Report an issue: GitHub.
Appendix: source
Thrown at lib/puppet/util/filetype.rb:284
Puppet::Util::Execution.execute(%w[crontab -l], cronargs)
rescue => detail
case detail.to_s
when /can't open your crontab/
""
when /you are not authorized to use cron/
Puppet.debug _("The %{path} user is not authorized to use cron. Their crontab file is treated as empty in case Puppet authorizes them in the middle of the run (by, for example, modifying the cron.deny or cron.allow files).") % { path: @path }
""
else
raise FileReadError, _("Could not read crontab for %{path}: %{detail}") % { path: @path, detail: detail }, detail.backtrace
end
end
# Remove a specific @path's cron tab.
def remove
Puppet::Util::Execution.execute(%w[crontab -r], cronargs)
rescue => detail
raise FileReadError, _("Could not remove crontab for %{path}: %{detail}") % { path: @path, detail: detail }, detail.backtrace
end
# Overwrite a specific @path's cron tab; must be passed the @path name
# and the text with which to create the cron tab.
def write(text)
# this file is managed by the OS and should be using system encoding
output_file = Tempfile.new("puppet_suntab", :encoding => Encoding.default_external)
begin
output_file.print text
output_file.close
# We have to chown the stupid file to the user.
File.chown(Puppet::Util.uid(@path), nil, output_file.path)
Puppet::Util::Execution.execute(["crontab", output_file.path], cronargs)
rescue => detail
raise FileReadError, _("Could not write crontab for %{path}: %{detail}") % { path: @path, detail: detail }, detail.backtrace
ensure
output_file.close
output_file.unlinkView on GitHub (pinned to e227c27540)