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

Variable substitution stopped working in version 1.7 #1914

Open
davidmneto opened this issue Jun 2, 2021 · 9 comments
Open

Variable substitution stopped working in version 1.7 #1914

davidmneto opened this issue Jun 2, 2021 · 9 comments
Assignees
Labels
bug a bug in the product Feature: configure
Milestone

Comments

@davidmneto
Copy link

davidmneto commented Jun 2, 2021

Brief Issue Summary

I am having an issue similar to the one described in #1526. I am trying to set the cmake.sourceDirectory using the variable ${buildKit} as follows:

"cmake.sourceDirectory": "${workspaceFolder}/project_1/${buildKit}",

I cannot configure the cmake project and I receive the error shown below.

I was able to later solve this by installing the previous version of cmaketools version. 1.6.0, and the substitution worked fine. I believe something broke in the transition to 1.7

CMake Tools Log

[expand] Invalid variable reference ${buildKit} in string: ${workspaceFolder}/project_1/${buildKit}
[rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"/workspaces/copateneida/project_1/${buildKit}"}

Platform and Versions

  • Operating System: Ubuntu 20.04
  • CMaketools Version: 1.7.3
@bobbrow
Copy link
Member

bobbrow commented Jun 4, 2021

Are you using CMakePresets.json to configure your project? Or are you using Kits and Variants?

@davidmneto
Copy link
Author

I believe I am using kits. I have configured the kits in a separate cmake-kits.json file. And I am setting the cmake.sourceDirectory in the settings.json

@bobbrow
Copy link
Member

bobbrow commented Jun 7, 2021

I see what happened. This commit disabled using certain variables in cmake.sourceDirectory. @andreeis can explain further. Is there a way we can make this work again?

// sourceDirectory cannot be defined based on any of the below variables.
buildKit: "",

@andreeis
Copy link
Contributor

andreeis commented Jun 8, 2021

Yes I can fix this. The original mistake on my part was that I was focused on scenarios where we want to identify if a project is or not a CMake project and that needs to happen before that annoying popup that we had about setting a kit. So I thought any kit information that is missing shouldn't block our analysis of having or not having a CMakeLists.txt (via "cmake.sourceDirectory"). But I didn't realize that if we do have a kit set then we need to expand any variables kit related. Quick fix.

@andreeis andreeis added bug a bug in the product quick fix the fix is estimated to be quick Feature: configure regression used to work and no longer does. Regressions are typically high priority IMPORTANT labels Jun 8, 2021
@andreeis andreeis added this to the 1.8.0 milestone Jun 22, 2021
@bobbrow bobbrow modified the milestones: 1.8.0, 1.9.0 Aug 17, 2021
@bobbrow bobbrow modified the milestones: 1.9.0, 1.10.0 Oct 19, 2021
@lygstate
Copy link
Contributor

Hwo to fix?

@bobbrow bobbrow modified the milestones: 1.10.0, On Deck Apr 6, 2022
@ToBoMi
Copy link

ToBoMi commented Nov 30, 2022

I try to use ${activeConfigurePresetName} in .vscode/settings.json and it is not getting evaluated.
${workspaceFolder} expansion works.

I use it as an argument to the clangd startup and it passes the non evaluated string ${activeConfigurePresetName} to the clangd call.
Is this behavior related to this issue?
I use CMakePresets.

@bobbrow
Copy link
Member

bobbrow commented Nov 30, 2022

@ToBoMi we support that feature, but your syntax is incorrect which is why it's not substituting it properly. Try ${command:cmake.activeConfigurePresetName}. (variable substitution documentation)

@ToBoMi
Copy link

ToBoMi commented Nov 30, 2022

Already tried that and many variations after reading the docs. None of them worked.
Here is the current output:

This:

    "clangd.arguments": [
        "--compile-commands-dir=${workspaceFolder}/${command:cmake.activeConfigurePresetName}",
    ]

leads to the following clangd call (I replaced some things with [...] in the workspace folder)

I[17:29:29.866] argv[1]: --compile-commands-dir=c:\Users\[...]\swdev\[...]/${command:cmake.activeConfigurePresetName}

@bobbrow
Copy link
Member

bobbrow commented Nov 30, 2022

We don't own the clangd.arguments setting. If that extension doesn't support command variable expansion, then you'll need to open an issue in that extension's repository to ask for the feature. VS Code does not do substitution on settings automatically. The extensions have to process it.

@gcampbell-msft gcampbell-msft modified the milestones: On Deck, 1.15 Jul 5, 2023
@andreeis andreeis added in progress actively being working on and removed quick fix the fix is estimated to be quick labels Jul 25, 2023
@gcampbell-msft gcampbell-msft modified the milestones: 1.15, 1.16 Aug 3, 2023
@benmcmorran benmcmorran modified the milestones: 1.16, 1.17 Nov 14, 2023
@gcampbell-msft gcampbell-msft modified the milestones: 1.17, Backlog Jan 16, 2024
@gcampbell-msft gcampbell-msft removed in progress actively being working on regression used to work and no longer does. Regressions are typically high priority labels Feb 16, 2024
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: configure
Projects
Status: Pending Prioritization
Development

No branches or pull requests

7 participants