Freesurfer recon-all Crashing Within fmriprep

Summary of what happened:

Hello all,
I am trying to run fmriprep on a dataset using a script that has previously run successfully, and I am getting a crash on the Freesurfer recon-all command. The autorecon1 node is exiting with the error: “must specify a subject id”, but I am passing the subject ID to the fmriprep job, so I’m not sure how to align those inputs.
The issue seems similar to the one described here, but I am already using the --cleanenv flag in my singularity/apptainer call.
Any advice is very welcome.

Command used (and if a helper script was used, a link to the helper script or the command generated):

singularity run --cleanenv \
  --no-home \
  -e \
  -B ${jobTmpDir}:/tmp \
  -B "/project/oathes_analysis2/templateflow:/templateflow" \
  -B "/appl/freesurfer-7.1.1:/freesurfer" \
  -B ${inputdir}:/data/input \
  -B ${outputdir}:/data/output \
  -B /project/oathes_analysis2/flexcoil/26Aug2025:/basepath
/project/oathes_analysis2/singularity_containers/fmriprep-23.2.3.simg \
/data/input /data/output participant \
--fs-license-file /freesurfer/license.txt \
--skull-strip-template OASIS30ANTs \
--output-spaces MNI152NLin6Asym T1w \
--bold2t1w-dof 6 \
--dvars-spike-threshold 1.5 \
--fd-spike-threshold 0.5 \
--ignore slicetiming \
--skip_bids_validation \
--notrack \
--nthreads 15 \
--omp-nthreads 14 \
--work-dir ${SINGULARITYENV_TMPDIR} \
--skip_bids_validation \
--stop-on-first-crash \
--verbose \
--participant-label $1

Version:

fMRIprep - 23.2.3
Freesurfer - 7.1.1

Environment (Docker, Singularity / Apptainer, custom installation):

Singularity/Apptainer via batch submission LPC

Relevant log outputs (up to 20 lines):

250916-13:05:39,804 nipype.workflow CRITICAL:
	 fMRIPrep failed: Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command
    raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node autorecon1.

Cmdline:
	recon-all -autorecon1 -i /tmp/fmriprep_23_2_wf/sub_DJO_wf/anat_fit_wf/anat_template_wf/denoise/mapflow/_denoise0/sub-DJO_ses-01_T1w_noise_corrected.nii.gz -noskullstrip -noT2pial -noFLAIRpial -openmp 14 -subjid sub-DJO -sd /data/output/sourcedata/freesurfer
Stdout:
	ERROR: must specify a subject id
Stderr:
	mktemp: failed to create file via template ‘/scratch/tmp.XXXXXXXXXX’: No such file or directory
	mktemp: failed to create file via template ‘/scratch/tmp.XXXXXXXXXX’: No such file or directory
	Traceback (most recent call last):
	  File "/opt/freesurfer/python/scripts/rca-config2csh", line 20, in <module>
	    configfile = sys.argv[1]
	IndexError: list index out of range
Traceback:
	RuntimeError: subprocess exited with code 1.

250916-13:05:41,143 cli ERROR:
	 Preprocessing did not finish successfully. Errors occurred while processing data from participants: DJO (1). Check the HTML reports for details.


Hi @jdickson14,

Can you add --writable-tmpfs to the singularity run preamble? Also, -e and --cleanenv are redundant together - only need one of them. I also don’t know how reliable the singularityenv tmpdir will be. Just specify one on your local file system.

Does the error persist on newer versions of fmriprep with a fresh working directory?

Are you trying to reuse any derivatives?

Best,
Steven