FileAlreadyExistsException when using copyTo on a directory that already exists #3887
-
Using Likely this is an issue that main.nf:#!/usr/bin/env nextflow
nextflow.enable.dsl=2
process sayHello {
input:
val x
output:
stdout
script:
"""
echo '$x world!'
"""
}
workflow {
Channel.of('Bonjour', 'Ciao', 'Hello', 'Hola') | sayHello | view
}
workflow.onComplete {
targetDir = "/tmp/tmpDir/"
workflow.workDir.copyTo(targetDir)
} .nextflow.log
|
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
The nextflow/modules/nf-commons/src/main/nextflow/extension/FilesEx.groovy Lines 167 to 209 in 4343e33 However it fails if the target is a file. Could that be the issue? |
Beta Was this translation helpful? Give feedback.
-
@bentsherman the place where I'd expect the exception to occur based on your reading isn't the same place that my stack trace above shows. I.e. in I think the issue is not the top-level source directory, but when visiting sub-directories here: |
Beta Was this translation helpful? Give feedback.
-
@bentsherman can you run the nextflow script and confirm it fails for you? |
Beta Was this translation helpful? Give feedback.
-
Whoops, forgot to look at your stack trace. I had to run the example three times before I encountered the error. The first time, it copies the Are you sure this is what you want? Even if it worked, you would be creating and endless recursion of |
Beta Was this translation helpful? Give feedback.
-
I think you need to use |
Beta Was this translation helpful? Give feedback.
-
Sure I could use rsync generally, but I’d like to use this an onError or onComplete block and use nextflow/Groovy to do so. I guess I am not following why it would create recursive directories when the target directory is always the same? |
Beta Was this translation helpful? Give feedback.
-
Try changing the
While I want it to overwrite what's there, I don't see why I think the recursive part may be a bug in the nextflow-io code? |
Beta Was this translation helpful? Give feedback.
-
You can use "rsync ${workflow.workDir} ${targetDir}".execute() The
I think you will find the same behavior whether you use |
Beta Was this translation helpful? Give feedback.
-
@bentsherman thank-you for your patience walking me through this! |
Beta Was this translation helpful? Give feedback.
You can use
rsync
in that workflow handler. In Groovy, you can callexecute()
on a string to execute it like a command:The
copyTo()
method does mimic the behavior ofcp -r
, which includes recursive copying of a directory. But you have to think about how the existence of the target affects the behavior:I thi…