In my case, I am getting this issue when the file being processed does not exist.
I fixed it by adding a condition(file.file.exists?
) to check whether the file exists or not calling recreate_versions!.
file.recreate_versions! if file.present? && crop_x.present?
file.recreate_versions! if file.present? && crop_x.present? && file.file.exists?