'How to get the path of the current temporary working directory in nextflow

I'm trying to create a file in the processes temporary directory that is checked by nextflow for output using the native scripting language (Groovy) of nextflow.

Here is a minimal example:

#!/usr/bin/env nextflow
nextflow.enable.dsl = 2

process test {
    echo true
    output:
        file('createMe')
    exec:
    path = 'createMe'
    println path
    output = file(path)
    output.append('exemplary file content')
}

workflow {
    test()
}

Simply creating the file in the current directory would work when using python as the scripting language, but here it fails with this message:

Error executing process > 'test'

Caused by:
  Missing output file(s) `createMe` expected by process `test`

Source block:
  path = 'createMe'
  println path
  output = file(path)
  output.append('exemplary file content')

Work dir:
  /home/some_user/some_path/work/89/915376cbedb92fac3e0a9b18536809

Tip: view the complete command output by changing to the process work dir and entering the command `cat .command.out`

I also tried to set the path to workDir + '/createMe', but the actual working directory seems to be a subdirectory of that path.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source