Skip to content

Fix nxf_date for uutils coreutils (Ubuntu 26.04+)#7118

Open
robsyme wants to merge 1 commit intomasterfrom
fix/7114-nxf-date-uutils
Open

Fix nxf_date for uutils coreutils (Ubuntu 26.04+)#7118
robsyme wants to merge 1 commit intomasterfrom
fix/7114-nxf-date-uutils

Conversation

@robsyme
Copy link
Copy Markdown
Collaborator

@robsyme robsyme commented May 7, 2026

Summary

  • Fixes nxf_date fails on images using uutils coreutils (e.g. ubuntu:latest → Ubuntu 26.04): Unexpected: unbound variable at .command.run line 178 #7114
  • nxf_date previously used date +%s%3N and dispatched on output length to extract a 13-digit millisecond epoch. uutils coreutils (default date on Ubuntu 26.04+) ignores the %3N field-width modifier and strips leading zeros from %N, producing a variable-length 11–19 digit string that hits no length branch and falls through to exit 1. The exit is swallowed by the surrounding local var=$(...), so callers get a literal error string assigned to start_millis / end_millis; the next arithmetic expansion then aborts under set -u with bash: line 178: Unexpected: unbound variable, killing the task.
  • Replaces the length-dispatch implementation with one that calls date +%s and date +%N separately, re-pads %N to 9 digits to recover any zeros uutils stripped, and computes milliseconds from the first three nanosecond digits. Non-numeric %N (BSD/macOS, where %N returns literal N) falls back to second precision, matching prior behaviour on those platforms.

Test plan

  • :nextflow:test --tests BashWrapperBuilderTest passes after fixture updates
  • Manual verification inside ubuntu:latest (uutils coreutils 0.8.0): produces 13-digit value with non-negative delta
  • Manual verification inside ubuntu:24.04 (GNU coreutils 9.4): produces 13-digit value with non-negative delta
  • CI runs full test suite

uutils coreutils ignores the %3N field-width modifier on `date` and strips
leading zeros from %N, so `date +%s%3N` returns a variable-length string
(11-19 digits) that no length branch in nxf_date matches. The function
falls through to `exit 1`, which is swallowed by the `local var=$(...)`
wrapper at the call site, leaving the caller with the literal error
string. The next arithmetic expression then triggers
"bash: line 178: Unexpected: unbound variable" under set -u and kills
the task.

Replace the length-dispatch implementation with a version that calls
`date +%s` and `date +%N` separately, re-pads %N to 9 digits to recover
any zeros uutils stripped, and computes milliseconds from the first
three nanosecond digits. Falls back to second precision when %N is
non-numeric (BSD/macOS), preserving existing behaviour on those
platforms.

Verified against both `ubuntu:latest` (uutils coreutils 0.8.0) and
`ubuntu:24.04` (GNU coreutils 9.4): both produce 13-digit values with
plausible non-negative wall-time deltas.

Fixes #7114

Signed-off-by: Rob Syme <rob.syme@gmail.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 7, 2026

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 56b62f3
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/69fcd111391aca000831789f

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.

nxf_date fails on images using uutils coreutils (e.g. ubuntu:latest → Ubuntu 26.04): Unexpected: unbound variable at .command.run line 178

1 participant