dedupe: respect dependency versions

Fixes issue #4675