Skip to content

Line number of error is incorrect #1256

@dariober

Description

@dariober

Snakemake version: 6.10.0 installed via bioconda/mamba

Describe the bug

When a snakefile contains a syntax error or some other bug, snakemake reports the wrong line number of the error. More specifically, it seems to me that:

  • The reported line number is consistently after the actual line number
  • As the Snakefile becomes longer, the difference between reported and actual line number grows
  • Earlier versions do not show this bug (e.g. v5.4.3 works)

This is quite a problem since it makes it difficult to locate bugs!

Minimal example

Here the syntax error is on line 9:

rule all:
    input:
        'done.txt',
        
rule trim_transcripts:
    output:
        done.txt,
    run:
        if 1 = 2:  # Syntax error: It should be 1 == 2
            print('foo')

Snakemake 6.10.0 reports the error on line 18:

snakemake -j 1 -n -s Snakefile2
SyntaxError in line 18 of /export/III-data/wcmp_bioinformatics/db291g/git_repos/wcip/20211109_kasia_asaj_snp/Snakefile2:
invalid syntax (Snakefile2, line 18)

Snakemake 5.4.3 is correct:

/export/projects/III-data/wcmp_bioinformatics/db291g/miniconda3/envs/20190312_andy_alba3_motifs/bin/snakemake -j 1 -n -s Snakefile2
SyntaxError in line 9 of /export/III-data/wcmp_bioinformatics/db291g/git_repos/wcip/20211109_kasia_asaj_snp/Snakefile2:
invalid syntax

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions