auto detect root directory