How to fix error `cached package a-x.y.z: size mismatch, cannot continue` during `pkg upgrade`?

Ben Woods woodsb02 at
Wed Feb 25 10:16:40 UTC 2015

I thought pkg(8) automatically deleted packages if they are the wrong size,
avoiding the need for a pkg clean?

Regardless, the following command will delete ALL cached packages (even
those that are still current). This means if you needed to reinstall the
packages, they will first need to be re-downloaded from the package
# pkg clean -a

Note: if the package you are downloading keeps having the wrong file
size/hash, it is probably the wrong size/hash on the server you are
downloading it from, meaning this solution will not help. This could be
because it is corrupt on the server, or simply because the server is half
way through syncing it's package mirror and the file download is
incomplete. Perhaps waiting a few hours will help in this case.


On Wednesday, February 25, 2015, Karl-Philipp Richter <
richter at> wrote:

> Hi,
> According to `man pkg` `pkg clean` should fix the issue, but doesn't. Is
> that a bug? Experienced with `pkg` 1.4.12 on FreeBSD 10.1.
> -Kalle


From: Benjamin Woods
woodsb02 at

More information about the freebsd-questions mailing list