# Error running containerised process if directory path contains spaces and hyphen

**URL:** https://community.seqera.io/t/error-running-containerised-process-if-directory-path-contains-spaces-and-hyphen/2446
**Category:** Ask for help
**Tags:** nextflow
**Created:** [November 13, 2025, 5:26pm UTC](https://community.seqera.io/t/error-running-containerised-process-if-directory-path-contains-spaces-and-hyphen/2446 "2025-11-13T17:26:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Rob](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/rob/32/2155_2.png) [@Rob](https://community.seqera.io/u/Rob)
#### Post date: [November 13, 2025, 5:26pm UTC](https://community.seqera.io/t/error-running-containerised-process-if-directory-path-contains-spaces-and-hyphen/2446/1 "2025-11-13T17:26:24Z")

</div>

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`):

```auto
#!/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:

```auto
#!/usr/bin/env Rscript

args <- commandArgs(trailingOnly = TRUE)
STR <- args[1]

print(STR)

```

And `nextflow.config`:

```auto
docker {
    enabled = true
    runOptions = '--rm'
}

process.debug = true // print to stdout

```

Running `nextflow run main.nf` results in the following output (`<...>` represents edited path):

```plaintext
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):

```auto
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](https://github.com/nextflow-io/nextflow/issues/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!

---

<div class="post-metadata">

### Author: ![yinshiyi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/yinshiyi/32/1091_2.png) [@yinshiyi](https://community.seqera.io/u/yinshiyi)
#### Post date: [November 21, 2025, 7:34pm UTC](https://community.seqera.io/t/error-running-containerised-process-if-directory-path-contains-spaces-and-hyphen/2446/2 "2025-11-21T19:34:20Z")

</div>

I tested the following in nextflow 24

```auto
git clone https://github.com/cjw85/wf-fun-times
cd into wf-fun-times
mkdir -p `dir with spaces - and hyphen`
cd into `dir with spaces - and hyphen`
nextflow ../fun\(\)times/main.nf 

```

It worked fine with the issue [https://github.com/nextflow-io/nextflow/issues/4572](https://github.com/nextflow-io/nextflow/issues/4572)

I can also confirmed that using your R script I was able to run it.

tree  
.  
├── bin  
│ ├── echo.sh  
│ └── script.R  
├── main.nf  
└── nextflow.config

pwd = ‘wf-fun-times/dir with spaces - and hyphen’
