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

[cmakefileapi-parser] Code model version (2.1) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect. #1341

Closed
pbaret opened this issue Jun 30, 2020 · 10 comments · Fixed by #1442

Comments

@pbaret
Copy link

pbaret commented Jun 30, 2020

I am trying to build a c++ project on windows with visual studio code and cmake-tools extension.

My versions are
cmake: 3.18.0-rc1
cmake tools (vscode extension): 1.4.1

When I build, I get this annoying message about codemodel version.

[cmakefileapi-parser] Code model version (2.1) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect.
[cmakefileapi-parser] Code model version (2.1) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect.

This messages appear at configuration, and also when I build.

It is the exact same problem mentionned by someone else in this stackoverflow question : https://stackoverflow.com/questions/62445673/cmakefileapi-parser-warning-message-about-cmake-in-windows-vscode

One of the comments on stackoverflow suggests to edit the file
\build\.cmake\api\v1\reply\codemodel-v2-[???].json and edit the minor version at the bottom of the file from '1' to '0'.

It does make the messages disappear for build after this changes, but as this file is generated at configuration, the warning comes back everytime you want to run cmake again...

Also I don't know if this modification breaks anything or not.

UPDATE: when writing this issue and checking my version of cmake, I figured out I was using a release candidate (for some reason it is the first displayed on cmake website and I did not pay attention when I downloaded it). I installed the latest cmake release (3.17.3) instead, and the problem "disappeared".

@bobbrow
Copy link
Member

bobbrow commented Jun 30, 2020

Thank you for reporting this issue. I saw it on another developer's machine this week and forgot to open a ticket to fix this. I looked for documentation from the CMake team about this revision but didn't find any. I posted a question on their forum to ask about the changes and we'll see what they say.

https://discourse.cmake.org/t/cmake-file-api-code-model-version-2-1/1465

Please note that the log message is just a warning and if the code model hasn't changed substantially in revision 2.1, the message can be safely ignored.

@bobbrow bobbrow added this to the 1.5.0 milestone Jun 30, 2020
@KyleFromKitware
Copy link
Contributor

if the code model hasn't changed substantially in revision 2.1, the message can be safely ignored.

CMake upstream here, this is a minor update which only adds new fields to the File API output - it won't break older clients. The warning is safe to ignore.

I've opened #1343 to suppress the warning for newer versions.

@bobbrow
Copy link
Member

bobbrow commented Sep 17, 2020

1.4.2 has this fix and is now available. Sorry for such a long delay, our work on another extension project has been taking much longer than anticipated.

@bobbrow bobbrow closed this as completed Sep 17, 2020
@bobbrow bobbrow modified the milestones: 1.5.0, 1.4.2 Sep 17, 2020
@Hary309
Copy link

Hary309 commented Sep 17, 2020

I'm on vscode-cmake-tools 1.4.2 and CMake 1.38.2 and this message still appears.

@KyleFromKitware
Copy link
Contributor

KyleFromKitware commented Sep 17, 2020

I'm on vscode-cmake-tools 1.4.2 and CMake 1.38.2 and this message still appears.

D'oh! Looks like I implemented the fix for the cache model but not the code model. I'll fix it.

KyleFromKitware added a commit to KyleFromKitware/vscode-cmake-tools that referenced this issue Sep 17, 2020
b6884ea allowd the cache object minor version to be higher than
expected, but did not do the same for the code model. Fix this.

Fixes: microsoft#1341
KyleFromKitware added a commit to KyleFromKitware/vscode-cmake-tools that referenced this issue Sep 17, 2020
b6884ea allowed the cache object minor version to be higher than
expected, but did not do the same for the code model. Fix this.

Fixes: microsoft#1341
@bpostalci
Copy link

I have vscode-cmake-tools 1.4.2 and CMake version 3.18.2 and encounter with this error

@bobbrow
Copy link
Member

bobbrow commented Sep 30, 2020

The remaining message will be fixed in 1.5

@jeremyxu2010
Copy link

I found a way to walkthrough the issue. edit ~/.vscode/extensions/ms-vscode.cmake-tools-1.4.2/dist/main.js, find the loadCodeModelContent function.

async function loadCodeModelContent(filename) {
    const file_content = await pr_1.fs.readFile(filename);
    const codemodel = JSON.parse(file_content.toString());
    const expected_version = { major: 2, minor: 0 };
    const detected_version = codemodel.version;
    if (detected_version.major != expected_version.major || detected_version.minor != expected_version.minor) {
        log.warning(localize(3, null, detected_version.major, detected_version.minor, expected_version.major, expected_version.minor));
    }
    return codemodel;
}

replace it with the code below:

async function loadCodeModelContent(filename) {
    const file_content = await pr_1.fs.readFile(filename);
    const codemodel = JSON.parse(file_content.toString());
    const expected_version = { major: 2, minor: 0 };
    const detected_version = codemodel.version;
    if (detected_version.major != expected_version.major || detected_version.minor < expected_version.minor) {
        log.warning(localize(3, null, detected_version.major, detected_version.minor, expected_version.major, expected_version.minor));
    }
    return codemodel;
}

Yes, just do as the PR did.

@HO-COOH
Copy link

HO-COOH commented Oct 14, 2020

@jeremyxu2010 The file ended up in ~/.vscode-server/extensions/ms-vscode.cmake-tools-1.4.2/dist/main.js on my machine.

@bobbrow bobbrow modified the milestones: 1.4.2, 1.5.0 Oct 20, 2020
@kevlut
Copy link

kevlut commented Oct 28, 2020

Getting this message when trying to configure a C project in VS Code:

[cmakefileapi-parser] Code model version (2.2) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect.
[cmakefileapi-parser] Code model version (2.2) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect.

cmake version 3.19.0-rc1
VS Code version 1.50.1
CMake for Visual Studio Code v0.0.17
CMake Tools v1.4.2

@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants