Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAMLException on configure #3727

Open
tysolov opened this issue Apr 29, 2024 · 7 comments
Open

YAMLException on configure #3727

tysolov opened this issue Apr 29, 2024 · 7 comments
Labels
bug a bug in the product Feature: variants
Milestone

Comments

@tysolov
Copy link

tysolov commented Apr 29, 2024

Brief Issue Summary

When opening project, custom variants in my cmake-variants.yaml file are not loaded, seemingly due to a parsing error in a markdown file:

title: README
...

# Large heading
Text
* Text with bullet  <!--- error here-->

## Another Header
More text

Due to this, my custom variants are not loaded upon opening vscode. However, editing the cmake-variants.yaml file in any way (e.g., adding a newline to end) forces a reload, at which point the custom variants show up without any ostensible parsing errors.

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.85.1",
  "cmtVersion": "1.18.31",
  "configurations": [
    {
      "folder": "/path/to/project",
      "cmakeVersion": "3.26.4",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {
        "C": "/usr/bin/gcc",
        "CXX": "/usr/bin/g++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 4,
    "executablesCount": 2,
    "librariesCount": 2,
    "targets": [
      {
        "name": "my_project",
        "type": "STATIC_LIBRARY"
      },
      {
        "name": "my_project_lib",
        "type": "STATIC_LIBRARY"
      },
      {
        "name": "my_project_unit_tests",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

...
[main] Copying compile_commands.json from /path/to/project/cmake-build-debug/compile_commands.json to /path/to/project/compile_commands.json
[expand] expanding /usr/bin/cmake
[expand] expanding -T
[expand] expanding test
[expand] expanding --output-on-failure
[variant] Error parsing /path/to/project/README.md: 
	YAMLException: name of an alias node must contain at least one character (7:2)
...
 7 | * Text with ...
------^
8 | 
 9 | ## Another Header ...
	at generateError (/path/to/.vscode/extensions/ms-vscode.cmake-tools-1.18.31/dist/main.js:27569:10)
	at throwError (/path/to/.vscode/extensions/ms-vscode.cmake-tools-1.18.31/dist/main.js:27573:9)
	at readAlias (/path/to/.vscode/extensions/ms-vscode.cmake-tools-1.18.31/dist/main.js:28737:5)
	at composeNode (/path/to/.vscode/extensions/ms-vscode.cmake-tools-1.18.31/dist/main.js:28836:20)
	at readBlockMapping (/path/to/.vscode/extensions/ms-vscode.cmake-tools-1.18.31/dist/main.js:28490:12)
	at composeNode (/path/to/.vscode/extensions/ms-vscode.cmake-tools-1.18.31/dist/main.js:28827:12)
	at readDocument (/path/to/.vscode/extensions/ms-vscode.cmake-tools-1.18.31/dist/main.js:29011:3)
	at loadDocuments (/path/to/.vscode/extensions/ms-vscode.cmake-tools-1.18.31/dist/main.js:29074:5)
	at Object.load (/path/to/.vscode/extensions/ms-vscode.cmake-tools-1.18.31/dist/main.js:29100:19)
	at VariantManager._reloadVariantsFile (/path/to/.vscode/extensions/ms-vscode.cmake-tools-1.18.31/dist/main.js:70751:41)
[variant] Loaded new set of variants

Additional Information

No response

@v-ericawu
Copy link
Collaborator

v-ericawu commented Apr 30, 2024

@gcampbell-msft We reproduced the issue as well using the following environment and steps:

ENV:

  • OS: Win10 22H2
  • VS Code version: 1.88.1
  • CMake Tools extension: 1.18.31(pre-release)

Repro Steps:

  1. Download and unzip Demo project.
  2. Open Demo project with VS Code.
  3. Observe OUTPUT.

Expected Result: yaml file won't parse error after opening CMake project.

Actual Result: yaml file parse error after opening CMake project:
image

CMake/Build: OUTPUT
[proc] Executing command: "E:\Program Files\CMake\bin\cmake.EXE" --version
[proc] Executing command: "E:\Program Files\CMake\bin\cmake.EXE" -E capabilities
[variant] Error parsing c:\Users\v-ericawu\Desktop\Demo\cmake-variants.yaml:
YAMLException: end of the stream or a document separator is expected (9:1)

6 | * Text with bullet <!--- error ...
7 |
8 | ## Another Header
9 | More text
-----^
at generateError (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:27569:10)
at throwError (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:27573:9)
at readDocument (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:29031:5)
at loadDocuments (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:29074:5)
at Object.load (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:29100:19)
at VariantManager._reloadVariantsFile (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:70751:41)
at async VariantManager.initialize (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:70904:9)
at async CMakeProject.init (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:44458:9)
at async CMakeProject.create (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:44695:9)
at async ProjectController.createCMakeProjectsForWorkspaceFolder (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:65831:27)
at async ProjectController.addFolder (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:65887:24)
at async ProjectController.loadAllProjects (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:65817:17)
at async ExtensionManager.init (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:57008:13)
at async activate (c:\Users\v-ericawu.vscode\extensions\ms-vscode.cmake-tools-1.18.31\dist\main.js:58756:5)
at async a.n (c:\Users\v-ericawu\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:142:6237)
at async a.m (c:\Users\v-ericawu\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:142:6200)
at async a.l (c:\Users\v-ericawu\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:142:5657)
[variant] Loaded new set of variants
[kit] Successfully loaded 7 kits from C:\Users\v-ericawu\AppData\Local\CMakeTools\cmake-tools-kits.json

@v-ericawu v-ericawu added bug a bug in the product Feature: variants and removed triage labels Apr 30, 2024
@gcampbell-msft
Copy link
Collaborator

@v-ericawu Is it possible that it is because it needs a new line at the end of the file?

@gcampbell-msft gcampbell-msft added the more info needed More info is needed from the community for us to properly triage and investigate. label Apr 30, 2024
@tysolov
Copy link
Author

tysolov commented Apr 30, 2024

For clarification, the parsing error shows up in file README.md ([variant] Error parsing /path/to/project/README.md: ); cmake-variants.yaml looks like so:

buildType:
  default: 'debug'
  choices:
    'debug':
      short: debug
      long: Add debug information.
      buildType: Debug
    'release':
      short: release
      long: Optimize generated code.
      buildType: Release
    'relwithdebinfo':
      short: relwithdebinfo
      long: Optimize generated code and add debug information.
      buildType: RelWithDebInfo

disableLogging:
  default: 'no'
  choices:
    'no':
      short: default logging
      long: Logging is enabled
      settings:
        DISABLE_LOGGING: false
    'yes':
      short: disable logging
      long: Disables logging to optimize performance.
      settings:
        DISABLE_LOGGING: true

re: new line at eof, this persists with new/no line at end of either file.

@gcampbell-msft
Copy link
Collaborator

@tysolov Interesting, I'm not sure why we'd be parsing the README file, this sounds like something to put on the backlog to investigate. Have you confirmed with other online yaml parsers that the format is correct? It looks like it is, but just as a double check. Thanks!

@gcampbell-msft gcampbell-msft removed the more info needed More info is needed from the community for us to properly triage and investigate. label May 1, 2024
@gcampbell-msft gcampbell-msft added this to the Backlog milestone May 1, 2024
@tysolov
Copy link
Author

tysolov commented May 1, 2024

@gcampbell-msft --- the fact that the [variant] step is processing anything other than cmake-variants file is certainly a concerning point of interest. That said, @v-ericawu's setup suggests it may be related.

cmake-variants.yaml and README.md have both been confirmed as valid using online parsers.

@tysolov
Copy link
Author

tysolov commented May 1, 2024

may be related: #3382

@Evelyn-001
Copy link
Collaborator

@tysolov, thanks for your reply. About this issue, we have reproduced this issue. Our developer team are investigating the issue and will get back to you with any updates. thank you for your support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in the product Feature: variants
Projects
Status: Pending Prioritization
Development

No branches or pull requests

4 participants