sort: invalid option -- '@'

That is the system sort, not samtools sort, because a variable in the command was empty

why

-@ is a samtools flag for thread count; the sort that ships with macOS and BSD has no such option. Seeing this means the shell ran its own sort. The usual cause is copying a command out of a pipeline log, where tools are referenced through environment variables that only exist while the pipeline runs: $SAMTOOLS sort -@ 4 with an empty $SAMTOOLS collapses to sort -@ 4. The pipeline is not necessarily broken. Your shell is just missing the variable.

what to do

Do not run commands copied straight out of a pipeline log. To reproduce a step by hand, put the real program name back: samtools sort -@ 4 .... The same goes for every $TOOL reference in that log.

traced · AMR++ on macOS, Biostars, Sep 2026
This is one entry from BioErrors, a catalogue of bioinformatics error messages that point at the wrong thing. Every entry was traced to its real cause before it was written down.
If your error is not in it, paste it there and it gets traced and added.