Could it be failing because of the dirname?