LDT
LDT

Reputation: 3108

ERROR nextflow.cli.Launcher - @unknown in Nextflow

I have just started learning nextflow and I have stumped on a weird error, for which I seek some guidance.

Here is my code

#!/usr/bin/env nextflow  
// Example1 from https://gist.github.com/elowy01/e9995d7ee8d6305930f868a10aeabbe9


params.str = 'Hello world!'

process AFcalc {

    """
    echo  '${params.str}'
    """
}

//this is necessary to print the output
result.subscribe {
    println it.trim()
}

When I run the code with

nextflow run example1.nf 

I am taking the following ERROR:

N E X T F L O W  ~  version 22.04.5
Launching `example1.nf` [nostalgic_brahmagupta] DSL2 - revision: 17976728a8
No such variable: result
 -- Check script 'example1.nf' at line: 15 or see '.nextflow.log' file for more details

when I look at the

less .nextflow.log

I am seeing this

Oct-02 13:51:35.370 [main] DEBUG nextflow.cli.Launcher - $> nextflow run example1.nf
Oct-02 13:51:35.413 [main] INFO  nextflow.cli.CmdRun - N E X T F L O W  ~  version 22.04.5
Oct-02 13:51:35.446 [main] DEBUG nextflow.cli.CmdRun - Applied DSL=2 by global default
Oct-02 13:51:35.460 [main] INFO  nextflow.cli.CmdRun - Launching `example1.nf` [nostalgic_brahmagupta] DSL2 - revision: 17976728a8
Oct-02 13:51:35.468 [main] DEBUG nextflow.plugin.PluginsFacade - Setting up plugin manager > mode=prod; plugins-dir=/Users/theodosiou/.nextflow/plugins; core-plugins: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
Oct-02 13:51:35.469 [main] DEBUG nextflow.plugin.PluginsFacade - Plugins default=[]
Oct-02 13:51:35.474 [main] INFO  org.pf4j.DefaultPluginStatusProvider - Enabled plugins: []
Oct-02 13:51:35.474 [main] INFO  org.pf4j.DefaultPluginStatusProvider - Disabled plugins: []
Oct-02 13:51:35.476 [main] INFO  org.pf4j.DefaultPluginManager - PF4J version 3.4.1 in 'deployment' mode
Oct-02 13:51:35.481 [main] INFO  org.pf4j.AbstractPluginManager - No plugins
Oct-02 13:51:35.511 [main] DEBUG nextflow.Session - Session uuid: ef770a53-e834-4fcd-8ae5-6216009b4ebc
Oct-02 13:51:35.511 [main] DEBUG nextflow.Session - Run name: nostalgic_brahmagupta
Oct-02 13:51:35.512 [main] DEBUG nextflow.Session - Executor pool size: 8
Oct-02 13:51:35.831 [main] DEBUG nextflow.cli.CmdRun - 
  Version: 22.04.5 build 5708
  Created: 15-07-2022 16:09 UTC (18:09 CEST)
  System: Mac OS X 12.6
  Runtime: Groovy 3.0.10 on Java HotSpot(TM) 64-Bit Server VM 17+35-LTS-2724
  Encoding: UTF-8 (UTF-8)
  Process: 50922@LOUKASs-Air [192.168.0.207]
  CPUs: 8 - Mem: 16 GB (90.5 MB) - Swap: 2 GB (356.6 MB)
Oct-02 13:51:35.840 [main] DEBUG nextflow.Session - Work-dir: /Users/theodosiou/Documents/Projects/nextflow/nextflow-example/work [Mac OS X]
Oct-02 13:51:35.840 [main] DEBUG nextflow.Session - Script base path does not exist or is not a directory: /Users/theodosiou/Documents/Projects/nextflow/nextflow-example/bin
Oct-02 13:51:35.846 [main] DEBUG nextflow.executor.ExecutorFactory - Extension executors providers=[]
Oct-02 13:51:35.851 [main] DEBUG nextflow.Session - Observer factory: DefaultObserverFactory
Oct-02 13:51:35.861 [main] DEBUG nextflow.cache.CacheFactory - Using Nextflow cache factory: nextflow.cache.DefaultCacheFactory
Oct-02 13:51:35.867 [main] DEBUG nextflow.util.CustomThreadPool - Creating default thread pool > poolSize: 9; maxThreads: 1000
Oct-02 13:51:35.903 [main] DEBUG nextflow.Session - Session start invoked
Oct-02 13:51:36.227 [main] DEBUG nextflow.script.ScriptRunner - > Launching execution
Oct-02 13:51:36.235 [main] DEBUG nextflow.Session - Session aborted -- Cause: No such property: result for class: Script_0f3fefb4
Oct-02 13:51:36.241 [main] ERROR nextflow.cli.Launcher - @unknown
groovy.lang.MissingPropertyException: No such property: result for class: Script_0f3fefb4
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:65)
        at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:341)
        at Script_0f3fefb4.runScript(Script_0f3fefb4:15)
        at nextflow.script.BaseScript.runDsl2(BaseScript.groovy:170)
        at nextflow.script.BaseScript.run(BaseScript.groovy:217)
        at nextflow.script.ScriptParser.runScript(ScriptParser.groovy:220)
        at nextflow.script.ScriptRunner.run(ScriptRunner.groovy:212)
        at nextflow.script.ScriptRunner.execute(ScriptRunner.groovy:120)
        at nextflow.cli.CmdRun.run(CmdRun.groovy:337)
        at nextflow.cli.Launcher.run(Launcher.groovy:480)
        at nextflow.cli.Launcher.main(Launcher.groovy:639)

I have checked other posts which suggest changing DSL=1 to DSL=2, but it does not affect my code. I know it's a silly question but some guidance at that level might help me kick start smoothly.

Upvotes: 1

Views: 1233

Answers (1)

Steve
Steve

Reputation: 54512

No such variable: result

Nextflow complains because you're trying to call the subscribe operator on a channel that hasn't been defined yet. Using the new DSL 2, you just need to define a workflow block to be able to call the process:

params.greeting = 'Hello world!'


process test {

    """
    echo '${params.greeting}'
    """
}

workflow {

    test()
}

Results:

$ nextflow run example1.nf 
N E X T F L O W  ~  version 22.04.4
Launching `example1.nf` [suspicious_bell] DSL2 - revision: 71213886a4
executor >  local (1)
[cc/9abb46] process > test [100%] 1 of 1 ✔

Then, to send the test process' stdout over a channel, simply define an output block. In this simple case, you can use the stdout qualifier here. To view the items in the output channel, simply call view to print them to your console:

params.greeting = 'Hello world!'


process test {

    output:
    stdout

    """
    echo '${params.greeting}'
    """
}

workflow {

    result = test()

    result.view()
}

Results:

$ nextflow run example1.nf 
N E X T F L O W  ~  version 22.04.4
Launching `example1.nf` [curious_raman] DSL2 - revision: 1fa31253d3
executor >  local (1)
[4e/bcd504] process > test [100%] 1 of 1 ✔
Hello world!

Upvotes: 1

Related Questions