nextflow icon indicating copy to clipboard operation
nextflow copied to clipboard

Add TMPDIR to Singularity/Apptainer auto-mounted directories

Open tdanhorn opened this issue 2 years ago • 0 comments

Bug report

This is somewhere between a bug report and a feature request. The current behavior can lead to unexpected consequences, tripping up even experienced users.

Expected behavior and actual behavior

It would be nice if we could use e.g. mktemp inside a container without worrying about bind-mounting directories. Adding $TMPDIR (and maybe $TMP) to the automatically mounted directories with autoMounts = true would accomplish this.

Currently the environment variable TMPDIR gets passed into a Singularity/Apptainer container (which is good) but the corresponding directory is often not accessible from inside the container, even with autoMounts = true. This will lead to an error in e.g. mktemp (or anything else honoring TMPDIR), which can be hard to debug if the user is not conscious that TMPDIR had been set (e.g. by the OS).

Steps to reproduce the problem

Set TMPDIR (either in the OS or in an env scope) to a directory that is not by default mounted by Singularity/Apptainer (e.g. /scratch). Set autoMounts = true in the applicable scope. A mktemp statement in the script section of a process will fail, unless something like runOptions = '-B /scratch' is set for the container engine.

Program output

(Copy and paste here output produced by the failing execution. Please highlight it as a code block. Whenever possible upload the .nextflow.log file.)

Environment

  • Nextflow version: 23.10
  • Java version: any compatible
  • Operating system: any
  • Bash version: any

Additional context

TMP is not POSIX but is often used like TMPDIR, so maybe treat it the same.

tdanhorn avatar Dec 14 '23 16:12 tdanhorn