diff --git a/xcp_d/cli/run.py b/xcp_d/cli/run.py index 4a814bd70..8f3a72e41 100644 --- a/xcp_d/cli/run.py +++ b/xcp_d/cli/run.py @@ -745,6 +745,16 @@ def _validate_parameters(opts, build_log): else: build_log.error(f"Freesurfer license DNE: {opts.fs_license_file}.") return_code = 1 + else: + fs_license_file = os.environ.get("FS_LICENSE", "/opt/freesurfer/license.txt") + if not Path(fs_license_file).is_file(): + build_log.error( + "A valid FreeSurfer license file is required. " + "Set the FS_LICENSE environment variable or use the '--fs-license-file' flag." + ) + return_code = 1 + + os.environ["FS_LICENSE"] = str(fs_license_file) # Check the validity of inputs if opts.output_dir == opts.fmri_dir: