I got help from a colleague and found out the answer. I write it here in case someone ends up with the same problem.I just needed to load the file as a different target. It is not enough to define the file, you also need to load it. The code would then look like:
list( tar_target( name = file, command = "data/PFTC4_Svalbard_2018_Gradient_Traits.csv", format = "file" ), tar_target( name = raw_traits, command = read_csv(file) tar_target( name = traits, command = clean_data(raw_traits) ), ...