Reputation: 29889
I have a .yaml
file like this:
title: 'We'll do cool stuff'
draft: true
However, I get the following error:
Error parsing YAML: YAMLException: can not read a block mapping entry;
a multiline key may not be an implicit key at line 2, column 6:
draft: true
^
How can I fix it?
Note: this setup seems different than the other questions where this same error was raised, including the following posts:
Upvotes: 3
Views: 24315
Reputation: 11
I have solved this issue by adding space between ":" and my variable value.
previous code -->
file_path:src/app.py
After change --->
file_path: src/app.py
It solved my issue.
Upvotes: 1
Reputation: 336
title: "We'll do cool stuff"
draft: true
I have got the exact same issue, The problem with it is, we are using a single quote'
in between the string and also wrapping the string with a single quote.
I resolved it by wrapping the string with a double quote.
You can also trace the issue more by reading this
Upvotes: 2
Reputation: 29889
You can use a site like YAML Formatter to format and validate your yaml:
In this case, the error message and location is a bit of red-herring.
The error is actually caused by a string that was accidentally terminated because of an unescaped quote symbol within the string. A hint for this is the syntax highlighting of 'We'll do cool stuff'
.
To fix, in this case, you can just skip wrapping the string quotes and rewrite like this:
title: We'll do cool stuff
draft: true
Upvotes: 7