Let us assume the code is identical because it does the same task for the same reason, not due to happenstance. Otherwise, there is nothing to talk about anyway.
A dependency can be a heavy burden.
It increases the need for coordinating any changes, hinders tailoring to the specific use-case where appropriate, and much of it will be or become useless for any one of the projects. This is exacerbated for non-compiled code, where unused code is an especially heavy dead weight.
Managing independent duplicates is also a heavy burden.
How will you track down (or even remember you should) all of them if you fix or improve any?
In all things, balance:
Is the functionality sufficiently complex and / or commonly needed?
Put it into the appropriate common library, which need not be a SO / DLL. The overhead is worth it and the extra scrutiny is welcome.
Is it small and easy enough, or should be tailored to the use-case?
Duplication might be a code smell, but that doesn't mean it isn't the smart choice.
Take the time to get it right.
Remember YAGNI and refactoring, the fewer depend on some interface, the easier it is to change, move, remove, or replace.
Retracting an interface is much more costly than promoting one, and having to keep it around is a drain.