Skip to content

fix: write .command.sh flush-left so <<- heredocs match (#43) - #44

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/43-dedent-command-sh
Jun 13, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/43-dedent-command-sh

Conversation

@scttfrdmn

Copy link
Copy Markdown
Collaborator

Closes #43.

Great progress upstream: #41 fixed staging, FASTQC ran, and one taxprofiler sample went all the way through. But the session still aborted on a malformed versions.yml:

Session aborted -- Cause: while scanning a simple key

Root cause

nf-core modules indent their process script and emit versions.yml via a <<-END_VERSIONS heredoc whose terminator sits at the same indentation. The <<- operator strips leading tabs only, never spaces. Nextflow normally writes .command.sh flush-left (common leading whitespace stripped), so the terminator ends up at column 0 and matches.

nf-spawn embedded task.script into its cat > .command.sh <<'NF_SPAWN_TASK_EOF' staging heredoc with the source indentation preserved. So the space-indented END_VERSIONS never matched the bare delimiter, the heredoc swallowed its own terminator (and everything after), and versions.yml came out malformed → SnakeYAML aborts the whole session. Affects essentially every nf-core module.

Fix

New dedentTaskScript() strips the longest common leading-whitespace prefix shared by all non-blank lines (blank lines ignored; relative indentation within the script preserved) before embedding — matching Groovy's stripIndent/Nextflow's behavior. Heredoc terminators now land at column 0 and <<- works.

Tests

38 total, 0 failures. Added: dedentTaskScript strips common indent / preserves relative indent / leaves flush-left & empty/null alone; and an end-to-end assertion that buildStagingScript emits the terminator at column 0 (\nEND_VERSIONS\nNF_SPAWN_TASK_EOF, no END_VERSIONS).

Built + tested on JDK 17 / Nextflow 26.04.x.

nf-spawn embedded task.script into the staging heredoc with its source
indentation preserved. nf-core modules indent their script body and emit
versions.yml via a `<<-END_VERSIONS` heredoc whose terminator sits at that
same indentation. `<<-` strips leading TABS only, not spaces — so the
space-indented terminator never matched, the heredoc swallowed it, and
versions.yml came out malformed, aborting the whole session with a SnakeYAML
`while scanning a simple key` error.

dedentTaskScript() now strips the longest common leading-whitespace prefix
(ignoring blank lines, preserving relative indentation) before embedding, the
way Nextflow writes .command.sh itself, so heredoc terminators land at column 0.
@scttfrdmn
scttfrdmn merged commit 55abe98 into main Jun 13, 2026
1 check passed
@scttfrdmn
scttfrdmn deleted the fix/43-dedent-command-sh branch June 13, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated .command.sh keeps the script indented, breaking <<- heredocs (malformed versions.yml → whole session aborts)

1 participant