update ensure_path() to raise error on failure