Fix a failed check

The check failed, in CI or on your machine, and you need to know what it wants. Every message names the file and the line, says what’s wrong, and often says what to do. This guide is the long form: it groups the messages by what they’re about, shows each one as the check prints it, and gives the fix. Find your message by its first words, or search this page for a phrase from it.

Table of Contents

What you’ll build

By the end of this guide you’ll have:

Before you start

The examples use the project of the other guides, my_app, here at version 0.2.0 in the GitHub repository me/my_app, with no [tools.dream_snippets] settings. Your messages name your own files, versions and repository.

Run the check from the project root:

Run the check Tested snippet

gleam run -m dream_snippets

Step 1: Find the place

The check prints one line for each problem, sorted by file and line, and a summary at the end. It stops with exit status 1 when there’s at least one problem. Here it is for a guide whose snippet changed:

A failed check Tested snippet

docs/guides/getting-started.md:5: the code block is not the same as test/snippets/guide_getting_started_greeting.gleam; the first difference is at line 9
1 block and 0 diff blocks checked in 3 files, 1 problem; 0 file blocks, 0 command blocks and 0 output blocks checked; 0 illustration blocks

The part before the second colon is the place: the file, then the line, counted from 1. For a code block, a badge above it, a diff block, or code at an older release, the line is the opening fence of the block. For a guide badge, it’s the heading. For a line of a diff block, a hidden Gleam line, an old 🧪 Tested source line, a gleam add line or a dependency line, it’s that line. For release notes, it’s the line of the section heading, or line 1 when something is missing.

Each message is exactly one line. A control character in a file name or a value, such as a line break, shows as \n, \r, \t or \u{<hex>}.

Step 2: Find the message

The rest is the reason. Match its first words with the sections below:

The message starts withSection
this gleam code block has no heading, the tested snippet badge is not, the old "🧪 Tested source"The heading and the badge
the badge link, the badge links to, cannot readThe badge link
the line anchor, the line rangeThe line range
the code block is not the same asThe code
this line looks like Gleam code, this code fence has no language, this code fence has no closing fenceOther fences
this <language> code block has no heading for a language that is not gleam or diff, the badge links to ... which is not under a tested_files pathBlocks of other languages
the package, the argument, this gleam add line, this dependency line, the requirement ofPackages and dependency lines
this README example heading, the guide badge, this heading has a guide badge, ... has no tested snippet badge that links to, has no "# " title line, this line links to a guideREADME examples and the guide badge
this diff block, the tested diff badge, the diff badge link, the compare link, the diff block, the hunk header, this line is not in "git diff, cannot run git, ... has no changes since the tagDiff blocks
the code at an older release badge, this heading has the code at an older release badge, the tag ... is not, which is not a file at the tagCode at an older release
a release notes file must be named, or any message that ends with see "Release notes template"Release notes
this block is in the docs of the release, or any message that names the release of these release notes or their own releaseDocs of an older release
error:Errors that stop the check

The heading and the badge

The heading and badge messages Tested snippet

docs/guides/getting-started.md:5: this gleam code block has no heading with the tested snippet badge directly above it (one blank line between is allowed)
docs/guides/getting-started.md:5: the tested snippet badge is not in the exact format; copy it from https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
docs/guides/getting-started.md:3: the old "🧪 Tested source" line is not used now; put the tested snippet badge at the end of the heading above the code block

The badge link

The badge link messages Tested snippet

docs/guides/getting-started.md:5: the badge link https://github.com/someone/my_app/blob/0.2.0/test/snippets/guide_getting_started_greeting.gleam does not point at a file in https://github.com/me/my_app
docs/guides/getting-started.md:5: the badge link uses the tag 0.1.0, but this file must link at the tag 0.2.0 (the docs of my_app use the version in gleam.toml)
docs/guides/getting-started.md:5: the badge links to test/snippets/greeting.gleam, which is not a file in this repository
docs/guides/getting-started.md:5: cannot read test/snippets/guide_getting_started_greeting.gleam: Permission denied

The line range

The line range messages Tested snippet

docs/guides/getting-started.md:5: the line anchor #L5:L9 is not #L<n> or #L<start>-L<end>
docs/guides/getting-started.md:5: the line range starts at line 9, after its end at line 5
docs/guides/getting-started.md:5: the line range ends at line 20, but the file has 16 lines

The code

The code messages Tested snippet

docs/guides/getting-started.md:5: the code block is not the same as test/snippets/guide_getting_started_greeting.gleam; the first difference is at line 9
docs/guides/getting-started.md:14: the code block is not the same as test/snippets/guide_getting_started_greeting.gleam#L13-L16; the first difference is at line 15

This is the message you’ll see most. The block and the file (or the line range of it) differ, and the first difference is at the line the message names, counted in the doc, not in the snippet.

Fix: copy the file or the lines into the block again. The snippet is the truth, because the tests run it. If a line range now points at the wrong lines, because lines were added above them, fix the numbers in the link instead. A few differences are hard to see: a tab instead of spaces, a trailing space, a missing last line. A whole-file block may leave out only the //// comment at the top of the file and the blank line after it.

Other fences

The fence messages Tested snippet

docs/guides/usage.md:4: this line looks like Gleam code in a text illustration code fence; put Gleam code in a gleam block with the tested snippet badge
docs/guides/usage.md:8: this code fence has no language; name the language of the block and prove it, or mark it as an illustration with "```text illustration"; see https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
docs/guides/usage.md:12: this code fence has no closing fence

Blocks of other languages

Every code block needs a proof. A block of any language other than gleam, diff and markdown is a copy of a file that the tests or CI use, with the same badge as a Gleam snippet:

The messages of blocks of other languages Tested snippet

docs/guides/deploy.md:5: this dockerfile code block has no heading with the tested snippet badge directly above it; link it to the file that it copies, or mark it as an illustration with "```dockerfile illustration"; see https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
docs/guides/deploy.md:12: this sh code block has no heading with the tested snippet badge directly above it; link it to the script that it copies, show only "gleam add" and "gleam deps update" lines, or mark it as an illustration with "```sh illustration"; see https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
docs/guides/deploy.md:18: this text code block has no heading with the tested snippet badge directly above it; link it to the output file that a test compares with the real output, or mark it as an illustration with "```text illustration"; see https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
docs/guides/deploy.md:25: the badge links to docs/deploy/Dockerfile, which is not under a tested_files path (test, .github); link to a file that the tests or CI use, and add its path to tested_files in [tools.dream_snippets] in gleam.toml; see https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html

In all four, a block that nothing can prove, such as a folder tree or a placeholder form, can be marked as an illustration instead: write illustration after the language, as in ```text illustration. The summary line counts illustrations, so a reviewer sees how many there are. Tested code blocks shows each form.

Packages and dependency lines

Two kinds of blocks are proven with no file. A command block of only gleam add and gleam deps update lines names packages that gleam.toml names. A toml block of only [dependencies] or [dev-dependencies] lines names the package of the project, with the requirement of the release of the document:

The package and dependency messages Tested snippet

README.md:12: the package gleam_jsn is not my_app and not a key of [dependencies] or [dev-dependencies] in gleam.toml; name only packages that this project uses; see https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
README.md:13: the argument my_app@1 is not a package name; a gleam add line holds package names and --dev, and a gleam deps update line holds package names; see https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
README.md:14: this gleam add line names no package; name the packages to add; see https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
README.md:20: this dependency line names gleam_json, but a toml block with no badge names only my_app; link the block to a file that the tests use; see https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
README.md:21: the requirement of my_app is ">= 0.1.0 and < 1.0.0", but the docs of this release use ">= 0.2.0 and < 1.0.0"; see https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html

README examples and the guide badge

The guide badge messages Tested snippet

README.md:5: this README example heading has no guide badge after its tested snippet badge; copy the heading from https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
README.md:5: the guide badge is not in the exact format, or it is not directly after the tested snippet badge; copy the heading from https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
README.md:5: the guide badge link https://hexdocs.pm/my_app/getting-started.html does not point at a file in https://github.com/me/my_app
README.md:5: the guide badge link uses the tag 0.1.0, but this file must link at the tag 0.2.0 (the docs of my_app use the version in gleam.toml)
README.md:5: the guide badge links to docs/usage.md, but it must link to a .md file under docs/guides
README.md:5: the guide badge link to docs/guides/getting-started.md has no #<anchor>, but it must name the guide section of this example
README.md:5: the guide badge links to docs/guides/greeting.md, which is not a file in this repository
README.md:5: the guide badge links to the anchor #greet-a-user, but docs/guides/getting-started.md has no heading with that anchor
README.md:5: docs/guides/getting-started.md has no tested snippet badge that links to test/snippets/guide_getting_started_greeting.gleam, but the guide of a README example must show that example
README.md:5: the guide badge must name its guide: alt="Guide: Getting started" and title="Guide: Getting started", from the "# " title line of docs/guides/getting-started.md
README.md:5: docs/guides/getting-started.md has no "# " title line outside code blocks, but the guide badge names its guide by that title
README.md:12: this line links to a guide from an example; remove it, because the guide badge on the example heading is the link to the guide
docs/guides/getting-started.md:3: this heading has a guide badge, but only README example headings have one; here the heading has only the tested snippet badge

Diff blocks

The diff block messages Tested snippet

docs/guides/upgrading.md:19: this diff block has no heading with the tested diff badge directly above it (one blank line between is allowed)
docs/guides/upgrading.md:19: the tested diff badge is not in the exact format; copy it from https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
docs/guides/upgrading.md:19: the diff badge link https://github.com/me/my_app/compare/0.1.0..0.2.0 is not https://github.com/me/my_app/compare/<old tag>...<new tag>#diff-<digest>
docs/guides/upgrading.md:19: the compare link ends at the tag 0.1.1, but this file must use the new tag 0.2.0 (the docs of my_app use the version in gleam.toml)
docs/guides/upgrading.md:19: the diff block does not start with "--- a/<path>" and "+++ b/<path>" for one path of letters, digits and . _ - /
docs/guides/upgrading.md:19: the diff block has no diff lines after its file header
docs/guides/upgrading.md:19: the compare link anchor is not the one for src/my_app.gleam; use #diff-dc300fec45bded4a328557d8cdb35d83594380337bd562985800e8086dc62ebd
docs/guides/upgrading.md:19: the tag 0.1.0 is not in this clone; fetch the tags with "git fetch --tags" (a shallow clone has none)
docs/guides/upgrading.md:19: cannot run git: git is not on the PATH
docs/guides/upgrading.md:19: cannot run git: git stopped with exit status 128
docs/guides/upgrading.md:19: src/my_app.gleam has no changes since the tag 0.1.0
docs/guides/upgrading.md:22: the hunk header @@ -1,4 +1,11 @@ is not a hunk header of the real diff, or it is out of order
docs/guides/upgrading.md:24: this line is not in "git diff 0.1.0 -- src/my_app.gleam" at this place; a diff block shows lines of the real diff, in order and contiguous within a hunk

Code at an older release

The code at an older release messages Tested snippet

docs/guides/upgrading.md:7: the code at an older release badge is not in the exact format, or the tag in its alt text or image is not the tag of its link; copy it from https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html
docs/guides/upgrading.md:7: this heading has the code at an older release badge and another badge, but a heading with that badge has no other badge
docs/guides/upgrading.md:7: the tag v0.1.0~1 or the path test/snippets/guide_upgrading_greet_lucy.gleam has characters that the check does not give to git (a tag has only letters, digits and . _ -, and a path also /)
docs/guides/upgrading.md:7: the tag 0.2.0 is not a release before 0.2.0, the version in gleam.toml, so use the tested snippet badge for this code
docs/guides/upgrading.md:7: the tag 0.1.0 is not in this clone; fetch the tags with "git fetch --tags" (a shallow clone has none)
docs/guides/upgrading.md:7: the badge links to test/snippets/guide_upgrading_greet_lucy.gleam, which is not a file at the tag 0.1.0
docs/guides/upgrading.md:7: the code block is not the same as test/snippets/guide_upgrading_greet_lucy.gleam#L4 at the tag 0.1.0; the first difference is at line 8
README.md:5: the code at an older release badge is only allowed in the guides under docs/guides and in release notes, because the README, the changelog and doc comments show only code of the current version

Release notes

The release notes name message Tested snippet

releases/notes-0.2.0.md:1: a release notes file must be named "release-<version>.md", for example "release-1.2.0.md"; see "Release notes template" in https://hexdocs.pm/dream_snippets/guides/release-notes-template.html

This one comes when a release_notes setting names a single file with another name. Fix: rename it to release-0.2.0.md. Every other release notes message is about the template, and Release notes template shows each one with its fix.

Docs of an older release

Release notes and a ## [<version>] changelog section belong to their own release. When that release is older than the version in gleam.toml, their blocks are compared with the files at its tag, and their diffs end at its tag. These messages are about them. Here gleam.toml says 0.2.0, and the notes are those of 0.1.0:

The messages of the docs of an older release Tested snippet

releases/release-0.1.0.md:11: the badge link uses the tag 0.2.0, but this file must link at the tag 0.1.0 (release notes and changelog sections link at the tag of their own release)
releases/release-0.1.0.md:11: the code block is not the same as test/snippets/guide_getting_started_greeting.gleam at the tag 0.1.0; the first difference is at line 15
releases/release-0.1.0.md:11: this block is in the docs of the release 0.1.0, so it is compared with the files at the tag 0.1.0, but that tag is not in this clone; fetch the tags with "git fetch --tags" (a shallow clone has none)
releases/release-0.1.0.md:17: the tag 0.1.0 is not a release before 0.1.0, the release of these release notes, so use the tested snippet badge for this code
releases/release-0.1.0.md:23: the compare link ends at the tag 0.2.0, but this file must use the new tag 0.1.0 (release notes and changelog sections link at the tag of their own release)
releases/release-0.1.0.md:23: src/my_app.gleam has no changes between the tags 0.0.1 and 0.1.0
releases/release-0.1.0.md:28: this line is not in "git diff 0.0.1 0.1.0 -- src/my_app.gleam" at this place; a diff block shows lines of the real diff, in order and contiguous within a hunk
releases/release-0.3.0.md:11: this block is in the docs of the release 0.3.0, which is neither 0.2.0, the version in gleam.toml, nor a release before it; set the version in gleam.toml to the release that these docs are for

Errors that stop the check

These come before any file is checked, on standard error, with exit status 1 and no summary:

The errors that stop the check Tested snippet

error: gleam.toml is not valid TOML: found m where value was expected
error: gleam.toml sets the key name twice
error: gleam.toml has no version = "..." line before its first [section]
error: gleam.toml has no name = "..." line before its first [section]
error: gleam.toml has no repository = { type = "github", user = "...", repo = "..." }
error: gleam.toml names a gitlab repository; the badges link at GitHub, so the repository type must be github
error: tools.dream_snippets.markdown in gleam.toml must be an array of strings, but its TOML type is String
error: tools.dream_snippets.markdown in gleam.toml must be an array of strings
error: tools.dream_snippets.guide in gleam.toml is not a setting; the settings are markdown, changelog, release_notes, gleam_source, checked_from_version, guides, badge_guide, release_notes_guide, tested_files
error: tools.dream_snippets.checked_from_version in gleam.toml is "1.0", which is not a major.minor.patch version
error: examples is set in [tools.dream_snippets] in gleam.toml, but it does not exist
error: Cannot read gleam.toml: No such file or directory
error: Cannot list docs: Permission denied

Settings and checks reference lists every setting with its type and default.

Test your code

The fastest way to see these messages is in your own test run. Use it from Gleam shows a one-line test that fails gleam test with the same lines the command prints.

Every message on this page is the real text. The tests of this guide build each problem, describe it with check.describe_problem as the command does, and assert the exact lines shown here.

Common pitfalls

Fixing the block when the snippet is wrong. Symptom: the check passes, and a reader’s copy of the example doesn’t work. Fix: when the block and the snippet differ, decide which one is right. If the block is right, change the snippet and its test first, then copy.

Many messages after a version bump. Symptom: every badge of the guides and the README fails with uses the tag. Fix: one search and replace of the old tag in the blob/<tag>/ links of those files fixes them all. Diff blocks of a guide need their new tag and their lines checked again. Release notes and changelog sections keep their own tag.

Problems only in CI. Symptom: is not in this clone in CI, while the check passes on your machine. Fix: fetch-depth: 0 in actions/checkout.

A message that points at your own page. Symptom: copy it from docs/contributing.md. Fix: nothing is wrong: your project set badge_guide or release_notes_guide. Those pages should show the same forms as this package’s guides.

Where to go next

✨ Search Document