tools::ensureDir is now more robust