The problem turned out to be that the directory workdir/.snakemake/scripts had become bogged down with many files (~600,000) from previous runs of the workflow. Deleting the old scripts there solved the problem.
workdir/.snakemake/scripts