This reminds me of the Node left-pad module problem in a way. I think if something is so trivial to write, you should write it rather than using a dependency.
If it is non-trivial, I prefer the official standard libraries for a programming language. That is if a solution exists in the standard library.
I think the Go standard library with its batteries included mantra and the level of support it gets is good example of a library that should be used when a solution exists within it or by utilizing it.
If you copy the code into your project you at least need to keep track of the original authors and licensing or you're in violation of the copyright 99% of the time.
If it is non-trivial, I prefer the official standard libraries for a programming language. That is if a solution exists in the standard library.
I think the Go standard library with its batteries included mantra and the level of support it gets is good example of a library that should be used when a solution exists within it or by utilizing it.