Fix nxf_date for uutils coreutils (Ubuntu 26.04+)#7118
Open
Fix nxf_date for uutils coreutils (Ubuntu 26.04+)#7118
Conversation
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>
✅ Deploy Preview for nextflow-docs-staging canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nxf_datefails on images using uutils coreutils (e.g.ubuntu:latest→ Ubuntu 26.04):Unexpected: unbound variableat.command.runline 178 #7114nxf_datepreviously useddate +%s%3Nand dispatched on output length to extract a 13-digit millisecond epoch. uutils coreutils (defaultdateon Ubuntu 26.04+) ignores the%3Nfield-width modifier and strips leading zeros from%N, producing a variable-length 11–19 digit string that hits no length branch and falls through toexit 1. The exit is swallowed by the surroundinglocal var=$(...), so callers get a literal error string assigned tostart_millis/end_millis; the next arithmetic expansion then aborts underset -uwithbash: line 178: Unexpected: unbound variable, killing the task.date +%sanddate +%Nseparately, re-pads%Nto 9 digits to recover any zeros uutils stripped, and computes milliseconds from the first three nanosecond digits. Non-numeric%N(BSD/macOS, where%Nreturns literalN) falls back to second precision, matching prior behaviour on those platforms.Test plan
:nextflow:test --tests BashWrapperBuilderTestpasses after fixture updatesubuntu:latest(uutils coreutils 0.8.0): produces 13-digit value with non-negative deltaubuntu:24.04(GNU coreutils 9.4): produces 13-digit value with non-negative delta