Move this logic to ruby instead and handle the case that the directory is missing.