ERROR ~ Cannot read write-only property: from

Hello, I cannot figure out how to fix this error. Here is a minimal reproducible example nextflow script:

#!/usr/bin/env nextflow

trigger_channel = Channel.value(true)

process TEST {
    input:
    val dummy_input from trigger_channel

    script:
    """
    #!/bin/bash
    RECEIVED_VALUE="${dummy_input}"
    echo "Received: \${RECEIVED_VALUE}!"
    """
}

workflow {
    TEST()
}

And this is the error that I get:

**N E X T F L O W** ~ version 25.04.4

Launching `hello.nf` [**tiny_pasteur**] DSL2 - revision: 9f12102eb8

ERROR ~ Cannot read write-only property: from

-- Check script 'hello.nf' at line: 7 or see '.nextflow.log' file for more details

Line 7 is “val dummy_input from trigger_channel.”

Here is the detailed error from .nextflow.log:

Jun-17 15:14:53.385 [main] DEBUG nextflow.Session - Session aborted -- Cause: Cannot read write-only property: from
Jun-17 15:14:53.390 [main] ERROR nextflow.cli.Launcher - @unknown
groovy.lang.GroovyRuntimeException: Cannot read write-only property: from
        at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:58)
        at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1387)
        at groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1335)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1088)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1007)
        at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
        at Script_ea2282ef16eedb5b$_runScript_closure1.doCall(Script_ea2282ef16eedb5b:7)
        at Script_ea2282ef16eedb5b$_runScript_closure1.doCall(Script_ea2282ef16eedb5b)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:280)

The problem is the mixing of DSL1 syntax with DSL2 syntax.
Channel input no longer use the from keyword. Instead these are passed as positional arguments to the process call in the workflow block.
Stricter syntax is also being introduced so you should only define channels inside workflow blocks.

So your script should look like this:

#!/usr/bin/env nextflow

process TEST {
    input:
    val dummy_input

    script:
    """
    #!/bin/bash
    RECEIVED_VALUE="${dummy_input}"
    echo "Received: \${RECEIVED_VALUE}!"
    """
}

workflow {
    def trigger_channel = Channel.value(true)
    TEST(trigger_channel)
}

Ideally, use an editor like VSCode with the Nextflow extension installed which includes a linter to catch these kind of errors. It can also interact with Seqera’s AI to write DSL2 compliant code which many other AI tools struggle with.

1 Like

Solved! Thank you very much!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.