No installers found when run from cron

I have a script that works when running from the command line (as root). However, if I cron it (as root, every 70 days), it gives me:

Updating letsencrypt and virtual environment dependencies…
Running with virtualenv: /root/.local/share/letsencrypt/bin/letsencrypt --renew-by-default
No installers seem to be present and working on your system; fix that or try running letsencrypt with the “certonly” command

Here’s the script:


cd /etc/letsencrypt/letsencrypt-tool

rm /tmp/certrenewal

echo “Starting renewal SSL Certificate Renewal for WWW.” >> /tmp/certrenewal
echo " " >> /tmp/certrenewal

echo “Creating, signing and installing new certificate for WWW:” >> /tmp/certrenewal
echo " " >> /tmp/certrenewal

echo “1” | ./letsencrypt-auto --renew-by-default >> /tmp/certrenewal 2>> /tmp/certrenewal

cat /tmp/certrenewal | mail -s “Let’s Encrypt SSL Certificate Renewal for WWW”

Here’s /etc/cli.ini:

authenticator = webroot
webroot-path = /var/www

# only use for testing
#server =

domains =

text = True

Why would putting it in a cron job make it fail to detect Apache?

Maybe this info helps:

That solved it. I set the PATH variable (to be the same as when logged in) at the begining of the script. It now works from the cron.