puppetlabs/puppet · error · FileReadError

Could not read crontab for

Error message

Could not read crontab for %{path}: %{detail}

What it means

Raised as FileReadError by the crontab filetype's read method (lib/puppet/util/filetype.rb:211) when running 'crontab -l' for user %{path} fails for reasons other than 'no crontab for' or 'not allowed to use cron' — e.g. the crontab binary is missing, or the command otherwise exits nonzero. The underlying command output is included as %{detail}.

Solutions

  1. Install or repair the crontab binary on the managed host.
  2. Inspect %{detail} for the actual crontab command failure and fix the OS-level cause.
  3. Verify the user %{path} exists and the agent has permission to run crontab for that user.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at lib/puppet/util/filetype.rb:211 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/9aea1402375347e8. Report an issue: GitHub.

Appendix: source

Thrown at lib/puppet/util/filetype.rb:211

    # Read a specific @path's cron tab.
    def read
      unless Puppet::Util.uid(@path)
        Puppet.debug _("The %{path} user does not exist. Treating their crontab file as empty in case Puppet creates them in the middle of the run.") % { path: @path }

        return ""
      end

      Puppet::Util::Execution.execute("#{cmdbase} -l", failonfail: true, combine: true)
    rescue => detail
      case detail.to_s
      when /no crontab for/
        ""
      when /are not allowed to/
        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
      cmd = "#{cmdbase} -r"
      if %w[Darwin FreeBSD DragonFly].include?(Puppet.runtime[:facter].value('os.name'))
        cmd = "/bin/echo yes | #{cmd}"
      end

      Puppet::Util::Execution.execute(cmd, failonfail: true, combine: true)
    end

    # Overwrite a specific @path's cron tab; must be passed the @path name
    # and the text with which to create the cron tab.
    #
    # TODO: We should refactor this at some point to make it identical to the
    # :aixtab and :suntab's write methods so that, at the very least, the pipe

View on GitHub (pinned to e227c27540)