Certbot on EC2 - couldn’t get currently installed version for /opt/eff.org/certbot/venv/bin/letsencrypt

Had to renew my client’s server SSL certificate today (hosted on AWS EC2), the certificate was created through the magnificent certbot (let’s encrypt). The command that I ran to renew the cert was:

sudo ./certbot-auto renew

When I ran the command above, certbot was self upgraded and then I encountered the following the error:

couldn’t get currently installed version for /opt/eff.org/certbot/venv/bin/letsencrypt

To fix the issue, I just had to remove the following the offending directory, by running:

sudo rm -rf /opt/eff.org/*

Re-run of sudo ./certbot-auto renew would work then.

I sort of stumbled the solution from certbot issue comment, the comment recommends installing certbot via pip but it wasn’t necessary in my case.