debugModerate
Error parsing YAML config file: yaml-cpp
Viewed 0 times
fileerrorcppconfigparsingyaml
Problem
I'm using the following command (Windows machine) with the MongoDB shell version: 3.0.7:
Contents of mongod.cfg file are given below:
Getting the below error:
Similar questions doesn't have the solutions for this.
What I've already tried:
Please help me with this.
mongod --config "G:\NodeApps\mongod.cfg" --installContents of mongod.cfg file are given below:
systemLog:
destination: file
path:"G:\NodeApps\data\log"
storage:
dbPath:"G:\NodeApps\data"Getting the below error:
Error parsing YAML config file: yaml-cpp: error at line 4, column 8: illegal map value
try 'mongod --help' for more informationSimilar questions doesn't have the solutions for this.
What I've already tried:
- I'm using spaces (not tabs)
- I'tried by saving the file in ASCII format, as It was mentioned in one of the posts that Mongod config file shouldn't be saved in non-ACSII format. Not even in UTF-8.
Please help me with this.
Solution
The error messages indicate the specific line and column where the YAML parser is having an issue with your configuration file, but if you're not familiar with the format it can be difficult to work out what is expected.
Two sets of changes are required to make your config valid YAML:
-
Add a "space" between the
YAML requires a space between key/value pairs, so reports: "error at line 4, column 8: illegal map value".
-
Remove the double quotes from your path values
YAML interprets backslashes inside quoted strings as introducing an escape character, so reports: "error at line 3, column 16: unknown escape character". As an alternative, you could also leave the path quoted but either escape the backslashes (
The following config should work (assuming
There are several online testers for YAML syntax that can be useful to troubleshoot problems (eg: YAML Lint).
Two sets of changes are required to make your config valid YAML:
-
Add a "space" between the
systemLog.path and storage.dbPath keys and their valuesYAML requires a space between key/value pairs, so reports: "error at line 4, column 8: illegal map value".
-
Remove the double quotes from your path values
YAML interprets backslashes inside quoted strings as introducing an escape character, so reports: "error at line 3, column 16: unknown escape character". As an alternative, you could also leave the path quoted but either escape the backslashes (
\\) or use forward slashes.The following config should work (assuming
"G:\NodeApps\data\" has the correct directory and file permissions):systemLog:
destination: file
path: G:\NodeApps\data\log
storage:
dbPath: G:\NodeApps\dataThere are several online testers for YAML syntax that can be useful to troubleshoot problems (eg: YAML Lint).
Code Snippets
systemLog:
destination: file
path: G:\NodeApps\data\log
storage:
dbPath: G:\NodeApps\dataContext
StackExchange Database Administrators Q#120027, answer score: 11
Revisions (0)
No revisions yet.