question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing of cmake-kits.json fails regularly

See original GitHub issue

Brief Issue Summary

Quite often I get the error message [kit] Failed to parse cmake-kits.json: {1} when changing the cmake-kits.json file. After saving the file a few times (without modifications) parsing will succeed. Sometimes this also seems to happen on start of VSCode.

Expected:

Consistent behavior if cmake-kits.json does not change. In the example below I’d expect the parsing of the file to succeed all the time.

CMake Tools Log

Log from saving a few times, cmake.loggingLevel is at trace.

[kit] Reading kits file c:\work\git\poquid\.vscode\cmake-kits.json
[kit] Failed to parse cmake-kits.json: {1}
[kit] Reading kits file c:\work\git\poquid\.vscode\cmake-kits.json
[kit] Failed to parse cmake-kits.json: {1}
[kit] Reading kits file c:\work\git\poquid\.vscode\cmake-kits.json
[kit] Successfully loaded 2 kits from c:\work\git\poquid\.vscode\cmake-kits.json
[kit] Reading kits file c:\work\git\poquid\.vscode\cmake-kits.json
[kit] Successfully loaded 2 kits from c:\work\git\poquid\.vscode\cmake-kits.json

Platform and Versions

  • Operating System: Windows 10
  • CMake Version: 3.15.1
  • VSCode Version: 1.45.0-insider
  • CMake Tools Extension Version: 1.3.1
  • Compiler/Toolchain: Keil ARMClang & Keil ARMCC with custom toolchain file

Other Notes/Information

cmake-kits.json being used (with minor modifications to my productive one, but the same issue can be observed here):

[
  {
    "name": "Keil armclang Chip1",
    "toolchainFile": "C:/work/git/cmake-keil/toolchain-keil-armclang.cmake",
    "cmakeSettings": {
      "TOOLCHAIN_PATH": "C:/ToolsRep",
      "DERIVATIVE": "Chip1",
      "LIB_PATH": "../lib"
    }
  },
  {
    "name": "Keil armcc Chip1",
    "toolchainFile": "C:/work/git/cmake-keil/toolchain-keil-armcc.cmake",
    "cmakeSettings": {
      "TOOLCHAIN_PATH": "C:/ToolsRep",
      "DERIVATIVE": "Chip1",
      "LIB_PATH": "../lib"
    }
  }
]

I know that the provided log is most likely quite insufficient to debug the issue. If there is any way I can provide additional information I’d be happy to do so.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
andreasWallnerIFXcommented, May 5, 2020

I did some additional checking, and as could be guesses from the exception it seems that the issue occurs during reading of the file, not the parsing. I added an additional output in the error case to dump the read file content:

...
} catch (e) {
  log.error(localize('failed.to.parse', 'Failed to parse {0}: {1} : {2}', "cmake-kits.json", e.message, e.stack));
  log.error(content_str)
  return [];
}
...

Testing with a cmake-kits.json just containing [] I can see that the content_str is empty.

[kit] Failed to parse cmake-kits.json: Unexpected EOF at line 1 column 2 of the JSON5 data. Still to read: "" : SyntaxError: Unexpected EOF at line 1 column 2 of the JSON5 data. Still to read: ""
  at error (c:\work\git\vscode-cmake-tools\dist\main.js:38451:25)
  at word (c:\work\git\vscode-cmake-tools\dist\main.js:38788:13)
  at value (c:\work\git\vscode-cmake-tools\dist\main.js:38888:56)
  at Object.parse (c:\work\git\vscode-cmake-tools\dist\main.js:38903:18)
  at Object.readKitsFile (c:\work\git\vscode-cmake-tools\dist\main.js:61774:26)
  at async KitsController.readKits (c:\work\git\vscode-cmake-tools\dist\main.js:61948:31)
[kit] 

I’ve not seen a case where only part of the file was read, always either all or nothing (also with bigger files). Just a wild guess: could it be that it’s reading the file in a state where the new content was not yet written? (assuming the write is not atomic)

cmake-kits.json vs user level cmake-tools-kits.json: The issue occurs for the user-level file as well, it seems to be more infrequent though.

Repro I’d be happy to provide a repository, but after the check of the user-level file I’m not sure that would help… I can reproduce the issue by opening a new workspace and placing a .vscode/cmake-kits.json file containing [] into it. Then I just repeatedly save the file. If you think it help I’d not have a problem generating that. Or just save the user-level kits file repeatedly.

0reactions
Neumann-Acommented, Sep 25, 2020

same issue here, deactivating Windows Defender does not help. (Working on a M2 SSD)

Read more comments on GitHub >

github_iconTop Results From Across the Web

vscode-cmake-tools/support - Gitter
I have error: Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit ......
Read more >
CMake server json parse error. - Visual Studio Feedback
A not too compicated CMake project fails to configure due to json parse errors. It is a project of mine found on github....
Read more >
vscode-cmake-tools - Bountysource
I have a test project using CMake. It builds fine if there is no CMakePresets.json file in the directory. But if the file...
Read more >
CMake Kits — CMake Tools 1.4.0 documentation
The .vscode/cmake-kits.json file can be committed to source control and shared ... about the compiler binary names and how to parse its version...
Read more >
Time Tracking Report - Qt Bug Tracker
Bug, QTCREATORBUG-27179, Closed, Not Evaluated, qml2puppet fails to build if quick3d is present ... Not Evaluated, encode settings key in json kit files....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found