Using the "Package support files for custom builds" method results in `caddy` going missing from the PATH

1. Output of caddy version:

-bash: caddy: command not found

2. How I run Caddy:

a. System environment:

I installed the Caddy package from apt and am now trying to use a custom build with the Cloudflare plugin installed. It’s a small Linode server running Debian 11.

b. Command:

sudo systemctl start caddy

c. Service/unit/compose file:

I’m not sure where to find this, but I don’t think that it is relevant.

d. My complete Caddy config:

I haven’t got this far yet.

3. The problem I’m having:

Because I need certificates for domains that point to local IPs, I’ve been trying to build Caddy with the Cloudflare plugin installed, since I use Cloudflare for my DNS. After building it successfully with xcaddy, I tried to follow the instructions for " Package support files for custom builds for Debian/Ubuntu/Raspbian" because I’d like to keep my configuration as close to “vanilla” Caddy as possible, but now whenever I try to execute a Caddy command, it reports that the command is not found.

4. Error messages and/or full log output:

-bash: caddy: command not found

5. What I already tried:

I tried undoing all the changes made by the instructions (removing the dpkg diversion and the update-alternatives group) and then uninstalling and reinstalling Caddy, as well as rebuilding the modified binary and ensuring it had execution permissions before copying it to /usr/bin as part of the steps.

6. Links to relevant resources:

Package support files for custom builds for Debian/Ubuntu/Raspbian - Build from Source - Caddy

dpkg-divert manpage

Well, the binary should be at /usr/bin/caddy. Make sure your PATH has /usr/bin in it.

This doesn’t seem like a problem with Caddy or the apt repo, there must be something pretty broken on your system if /usr/bin isn’t in your PATH.

You can try sudo apt purge caddy which should do a better job of wiping everything out instead of remove, i.e. including config files and such.

It’s pretty hard to suggest anything without knowing exactly what commands you ran. I’d suggest maybe just wiping out the whole VM and re-creating a new one. That’s easy and quick with a VPS from Linode or similar. Obviously backup anything you’ve put on there first.

I found the problem. I had a folder called caddy in my home directory, which was affecting commands. It was moving the folder ./caddy instead of the executable ./caddy.

2 Likes

Hah, yep that would do it!

Thanks for following up!