Use Pathname#find since Pathname#detect does not exist

Fixes regression introduced by #4f92c13e1f8.