Variable is already defined when file content relative to baseDir is stored in a def #4216
Replies: 2 comments 1 reply
-
Is this code happening inside a function? or a process? or the main script? Also, you can try using |
Beta Was this translation helpful? Give feedback.
-
I have a main.nf and a setup.nf in folder $baseDir/bin Code is happening inside exec: - block of a process in setup that is used to check params for flags and required input. Problem is not that I cannot access via $baseDir, but that a String inside a file in "$baseDir/res/Help.txt" can be accessed via println file("${baseDir}/res/Help.txt").text without problems, however, if i try to store the String in a def via def storedstring= file("${baseDir}/res/Help.txt").text I get the baseDir is allready defined crash. |
Beta Was this translation helpful? Give feedback.
-
I am currently setting up a subroutine to check my pipeline parameters and provide an extended usage information upon missing parameters.
-->This throws an Error:
ERROR ~ Module compilation error
file : $PATH_TO_BASEDIR/./bin/Setup.nf
cause: Variable
baseDir
already defined in the process scope @ line 58, column 28.Line 58 is def myoutput= file("${baseDir}/res/Help.txt").text
-->This runs fine
Since I would like to color the output, I would need adjust myoutput by adding ANSI.
e.g. the following works like a charm.
Currently I do not see what could be wrong before I even reach the ANSI. As for my understanding I do not define baseDir anywhere but only use it in a relative path.
baseDir does not occur in Help.text, no $baseDir in that file either.
Beta Was this translation helpful? Give feedback.
All reactions