Hello,
I encounter an error when trying to run a process on my local machine using a container (either Docker or Apptainer) in a directory which contains spaces and a hyphen. (Unfortunately I can’t change the directory name because this is on a work laptop, controlled by my organisation…)
This is illustrated by the following example, run in the project directory dir with spaces - and hyphen/ (on the same machine, but outside of the home directory containing spaces and hyphen). (I can confirm that this definitely works when run in a directory whose full path contains no spaces/hyphens on the same machine.)
Nextflow script (main.nf):
#!/usr/bin/env nextflow
process MY_PROCESS {
container 'rocker/r-ver'
input:
val STR
output:
stdout
script:
"""
script.R "${STR}"
"""
}
params.my_string = 'Hello World!'
workflow {
MY_PROCESS( params.my_string )
}
Corresponding R script (script.R), in the bin/ subdirectory:
#!/usr/bin/env Rscript
args <- commandArgs(trailingOnly = TRUE)
STR <- args[1]
print(STR)
And nextflow.config:
docker {
enabled = true
runOptions = '--rm'
}
process.debug = true // print to stdout
Running nextflow run main.nf results in the following output (<...> represents edited path):
ERROR ~ Error executing process > 'MY_PROCESS'
Caused by:
Process `MY_PROCESS` terminated with an error exit status (127)
Command executed:
script.R "Hello World!"
Command exit status:
127
Command output:
(empty)
Command error:
/bin/bash: line 1: export: `-': not a valid identifier
/bin/bash: line 1: export: `hyphen/bin': not a valid identifier
.command.sh: line 2: script.R: command not found
Work dir:
/mnt/c/<...>/dir with spaces - and hyphen/work/74/22ac88d955b77e3edf2b049e9c47d3
Container:
rocker/r-ver
Tip: you can replicate the issue by changing to the process work dir and entering the command `bash .command.run`
-- Check '.nextflow.log' file for details
Checking .command.run in the work directory, the path exported by nxf_container_env() is as follows, with unescaped spaces (again, <...> represents edited path):
nxf_container_env() {
cat << EOF
export PATH="\$PATH:/mnt/c/<...>/dir with spaces - and hyphen/bin"
EOF
}
When I manually escape all spaces with \ and re-run .command.run, everything works perfectly.
I believe this matches a previously identified issue (“Docker enabled is failing if the directory contains special characters” #4572), although this has apparently been solved…?
I am running Nextflow 25.10.0 (build 10289) on WSL2 with Ubuntu 22.04.5 LTS,
- Java: openjdk version 21.0.8
- Bash: GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
- Docker version 28.5.1 (build e180ab8), Apptainer version 1.4.4.
Any help would be appreciated!