What types are possible for process outputs?

I am experimenting with how processes work. The hello nextflow tutorial demonstrates that inputs can be typed as path or val. I found this documentation page that describes what is acceptable as an input and output: Process reference | Seqera Docs

I was a little surprised that the tutorial seems to describe legacy inputs and outputs, or that I seemingly don’t understand how to read the documentation.

I have attempted to output a value from a process, but it is not working. I do not know what I am doing wrong.

process sayHello {
    input:
    val greeting

    output:
    val "${random_variable}"
    path 'output.txt'

    script:
    """
    echo '${greeting}' > output.txt
    export random_variable="Cheese"
    """
}

Error hello-world.nf:14:12: `random_variable` is not defined
│  14 |     val "${random_variable}"
╰     |            ^^^^^^^^^^^^^^^

I don’t strictly understand what the val output is for, but I had guessed that it was a wau to export variables that might be created within the script.

To be fair to the training, the typed syntax is still pretty new and only became semi-stable in 26.04 . I imagine they will start teaching the typed syntax before long

As for your example, random_variable is an environment variable, so you need to use env to capture it. val would only be used to capture a Nextflow variable, for example:

process sayHello {
    input:
    val greeting

    output:
    val "${random_variable}"
    path 'output.txt'

    script:
    random_variable = "Cheese"
    """
    echo '${greeting}' > output.txt
    """
}

The val output is usually only used to forward inputs, like if you wanted to include greeting with the output file. The env is also less common because you can always just write the env value to a file and capture it with path. So we typically just focus on path and val.

As Ben says, typed processes are in preview right now. We will update the training to use them for the next major refresh at the end of the year.

The training does cover typed params, which are stable in Nextflow 25.10+.