Skip to content

Commit f519e56

Browse files
committed
Use toUriString for paths in work-dir and FilesEx error messages
Paths backed by non-default filesystems (e.g. S3, Azure) render as opaque provider objects when interpolated directly into a GString. Wrap them with toUriString so diagnostic messages show a usable URI in the work-dir abort and in FilesEx permission/modify-time failure logs. Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
1 parent cb7133d commit f519e56

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

modules/nextflow/src/main/groovy/nextflow/Session.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import nextflow.exception.MissingLibraryException
5454
import nextflow.exception.ScriptCompilationException
5555
import nextflow.executor.ExecutorFactory
5656
import nextflow.extension.CH
57+
import nextflow.extension.FilesEx
5758
import nextflow.file.FileHelper
5859
import nextflow.file.FilePorter
5960
import nextflow.plugin.Plugins
@@ -82,7 +83,6 @@ import nextflow.trace.event.TaskEvent
8283
import nextflow.trace.event.WorkflowOutputEvent
8384
import nextflow.util.Barrier
8485
import nextflow.util.ClassLoaderFactory
85-
import nextflow.util.Duration
8686
import nextflow.util.HistoryFile
8787
import nextflow.util.LoggerHelper
8888
import nextflow.util.NameGenerator
@@ -445,7 +445,8 @@ class Session implements ISession {
445445
*/
446446
Session init( ScriptFile scriptFile, List<String> args=null, Map<String,?> cliParams=null, Map<String,?> configParams=null ) {
447447

448-
if(!workDir.mkdirs()) throw new AbortOperationException("Cannot create work-dir: $workDir -- Make sure you have write permissions or specify a different directory by using the `-w` command line option")
448+
if(!workDir.mkdirs())
449+
throw new AbortOperationException("Cannot create work-dir '${FilesEx.toUriString(workDir)}' -- Make sure you have write permissions or specify a different directory by using the `-w` command line option")
449450
log.debug "Work-dir: ${workDir.toUriString()} [${FileHelper.getPathFsType(workDir)}]"
450451

451452
if( config.bucketDir ) {

modules/nf-commons/src/main/nextflow/extension/FilesEx.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ class FilesEx {
495495
return true
496496
}
497497
catch(IOException e) {
498-
log.debug "Failed to create directory '$self'", e
498+
log.debug "Failed to create directory '${toUriString(self)}'", e
499499
return false
500500
}
501501
}
@@ -515,7 +515,7 @@ class FilesEx {
515515
Files.isReadable(self)
516516
}
517517
catch( IOException e ) {
518-
log.trace("Cannot get read permission on file: $self -- Cause: ${e.getMessage()}")
518+
log.trace("Cannot get read permission on file '${toUriString(self)}' -- Cause: ${e.getMessage()}")
519519
return false
520520
}
521521
}
@@ -536,7 +536,7 @@ class FilesEx {
536536
Files.isWritable(self)
537537
}
538538
catch( IOException e ) {
539-
log.trace("Cannot get write permission on file: $self -- Cause: ${e.getMessage()}")
539+
log.trace("Cannot get write permission on file '${toUriString(self)}' -- Cause: ${e.getMessage()}")
540540
return false
541541
}
542542
}
@@ -560,7 +560,7 @@ class FilesEx {
560560
Files.isExecutable(self)
561561
}
562562
catch( IOException e ) {
563-
log.trace("Cannot get execute permission on file: $self -- Cause: ${e.getMessage()}")
563+
log.trace("Cannot get execute permission on file '${toUriString(self)}' -- Cause: ${e.getMessage()}")
564564
return false
565565
}
566566
}
@@ -590,7 +590,7 @@ class FilesEx {
590590
Files.getLastModifiedTime(self,options).toMillis()
591591
}
592592
catch( IOException e ) {
593-
log.trace "Cannot get lastModified time on file: $self -- Cause: ${e.getMessage()}"
593+
log.trace "Cannot get lastModified time on file '${toUriString(self)}' -- Cause: ${e.getMessage()}"
594594
return 0
595595
}
596596
}

0 commit comments

Comments
 (0)