Caddy EXE upgrade is failing

1. Caddy version (caddy version): 2.4.5

2. How I run Caddy:

a. System environment:

Win10 x64 v21H2

b. Command:

D:\BIN\caddy>caddy_windows_amd64.exe upgrade

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

Paste config here, replacing this text.
Use `caddy fmt` to make it readable.
DO NOT REDACT anything except credentials.
LEAVE DOMAIN NAMES INTACT.
Make sure the backticks stay on their own lines.

3. The problem I’m having:

The new EXE downloads but then the replacement fails.

4. Error messages and/or full log output:

Version:
v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=

upgrade: download succeeded, but unable to clean up backup binary: remove D:\BIN\caddy\caddy_windows_amd64.exe.tmp: Access is denied.

5. What I already tried:

The error seems misleading: the *.tmp file is removed.
Elevated CMD prompt did not help.

6. Links to relevant resources:

Unfortunately, that was a bug that existed in versions before v2.4.6, but I’ve fixed it for the v2.4.6 release, so it should now work for any future upgrades.

Basically the problem is that Windows would deny access to the temporary backup since it tries to prevent the currently running process from deleting itself. The workaround is that Caddy will delegate the deletion to cmd.exe, so it’s actually another process that will delete it.

Now that you’ve upgraded to v2.4.6, you can play around with the caddy add-package and caddy remove-package commands, you should see that the backup is indeed removed (you can also use --keep-backup to prove that it does indeed create the backup as an intermediate step, and skip deleting it)

Thanks.

A nice enhancement would be to put the version number in the file properties so the version can be checked w/o having to run Caddy.

This topic was automatically closed after 30 days. New replies are no longer allowed.