How to Fix 'The error was: NoInstallationError("Could not find a usable 'nginx' binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.",)'

Tadashi Shigeoka ·  Fri, October 2, 2020

I’ll show you how to resolve the error The error was: NoInstallationError(“Could not find a usable ‘nginx’ binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.”,).

Let's Encrypt

Background: certbot-auto renew --nginx Error in crontab

The process set up in How to Set Up Automatic SSL Certificate Renewal with Let’s Encrypt using certbot and crontab was failing with an error.

Solution: Set PATH Properly

The following error message was output in the cron execution log:

Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/codenote.net.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Non-interactive renewal: random delay of 18.66088887793885 seconds
Could not choose appropriate plugin: The nginx plugin is not working; there may be problems with your existing configuration.
The error was: NoInstallationError("Could not find a usable 'nginx' binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.",)
Attempting to renew cert (codenote.net) from /etc/letsencrypt/renewal/codenote.net.conf produced an unexpected error: The nginx plugin is not working; there may be problems with your existing configuration.
The error was: NoInstallationError("Could not find a usable 'nginx' binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.",). Skipping.
All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/codenote.net/fullchain.pem (failure)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/codenote.net/fullchain.pem (failure)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 renew failure(s), 0 parse failure(s)

As the error message The error was: NoInstallationError(“Could not find a usable ‘nginx’ binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.”,) indicates, the PATH is not set properly, so let’s review the crontab PATH.

$ crontab -l
PATH=/usr/local/bin:/bin:/usr/bin

$ which nginx
/usr/sbin/nginx

Since this was the situation, you just need to add /usr/sbin to the PATH in crontab as follows:

$ crontab -l
PATH=/usr/local/bin:/usr/sbin:/bin:/usr/bin

That’s all from the Gemba, where we faced a crontab PATH configuration oversight issue.

Reference Information