Skip to content

Commit b535377

Browse files
authored
Use toUriString for paths in work-dir and FilesEx error messages (#7075)
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 b58a590 commit b535377

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
@@ -55,6 +55,7 @@ import nextflow.exception.MissingLibraryException
5555
import nextflow.exception.ScriptCompilationException
5656
import nextflow.executor.ExecutorFactory
5757
import nextflow.extension.CH
58+
import nextflow.extension.FilesEx
5859
import nextflow.file.FileHelper
5960
import nextflow.file.FilePorter
6061
import nextflow.plugin.Plugins
@@ -83,7 +84,6 @@ import nextflow.trace.event.TaskEvent
8384
import nextflow.trace.event.WorkflowOutputEvent
8485
import nextflow.util.Barrier
8586
import nextflow.util.ClassLoaderFactory
86-
import nextflow.util.Duration
8787
import nextflow.util.HistoryFile
8888
import nextflow.util.LoggerHelper
8989
import nextflow.util.NameGenerator
@@ -446,7 +446,8 @@ class Session implements ISession {
446446
*/
447447
Session init( ScriptFile scriptFile, List<String> args=null, Map<String,?> cliParams=null, Map<String,?> configParams=null ) {
448448

449-
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")
449+
if(!workDir.mkdirs())
450+
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")
450451
log.debug "Work-dir: ${workDir.toUriString()} [${FileHelper.getPathFsType(workDir)}]"
451452

452453
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)