Fixing duplicate UID errors when using mbsync and mu4e

This is a particularly niche post but hopefully will save someone the time I spent trying to solve this problem.

I have migrated from offlineimap to mbsync (part of isync) for synchronising my local email with Gmail. mbsync is much faster and I’ve been happy with the switch but I kept encountering error messages from mbsync about duplicate UIDs. The form of the message was Maildir error: duplicate UID 12 (or some other number).

After a lot of digging around I found the solution was in the mbsync and mu4e manuals (of course). The problem is caused because mu4e does not by default rename files when moving them to a new directory and this then causes problems for mbsync. This is easily fixed by setting

(setq mu4e-change-filenames-when-moving t)
  • JohnKitchin

    Any chance you documented your transition? I have contemplated this switch too, but I haven’t wanted to mess up my email mid semester 😉

    • I’m also mid-semester but thought I’d take my chances. There wasn’t much to document really, but I’ll put together a quick post to describe what I did so I can format it more nicely…

  • mgalgs

    Dang I’m having this exact same problem with gnus, or at least the same symptom… I wonder if there’s an equivalent option in gnus…

  • Russell Black

    This was my exact problem. Thanks for posting the fix!

    • I’m glad that helped – I’m hoping this page turns up high in google searches to save others the hours of frustration that I had!

  • vale981

    Geez! Neat.
    Second rank in the google search.