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

Presets are not reloaded when an included file is changed until reloading the whole project #3963

Closed
Hugal31 opened this issue Aug 7, 2024 · 12 comments · Fixed by #4172
Closed
Assignees
Labels
bug a bug in the product Feature: presets
Milestone

Comments

@Hugal31
Copy link

Hugal31 commented Aug 7, 2024

Brief Issue Summary

When adding an include directive in a CMake preset, any change made to the included files won't trigger a reload of the presets. Any further CMake configure will not take in account the changes, until the CMake(User)Presets.json is modified or VSCode is restarted.

If VSCode is restarted, then the included file seems to be added to the watches and it works as expected.

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.91.1",
  "cmtVersion": "1.18.44",
  "configurations": [
    {
      "folder": "/tmp/testcode",
      "cmakeVersion": "3.29.6",
      "configured": true,
      "generator": "Unix Makefiles",
      "usesPresets": true,
      "compilers": {
        "C": "/usr/bin/cc",
        "CXX": "/usr/bin/c++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [
      ""
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

No response

Additional Information

To reproduce:
Create a preset-based project
In the CMakeLists.txt, display a cache or env variable.
Use the "include" directive in the preset and in the main CMakePresets.txt, inherit from a configurePreset.
Change the varaible in the included preset file.

E.g.

# CMakeLists.txt
message("THE_VAR is $ENV{THE_VAR}")
message("THE_OTHER_VAR is ${THE_OTHER_VAR}")

CMakePresets.json:

{
    "version": 4,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 23
    },
    "include": ["presets.json" ],
    "configurePresets": [
        {
            "name": "Debug",
            "inherits": "base"
        }
    ]
}

presets.json

{
    "version": 4,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 23
    },
    "configurePresets": [
        {
            "name": "base",
            "cacheVariables": {
                "THE_OTHER_VAR": "2"
            },
            "environment": {
                "THE_VAR": "2"
            }
        }
    ]
}

Then try to change the variables in presets.json and reconfigure. The changes are not taken in account.
Restart VSCode and it works fine.

@gcampbell-msft
Copy link
Collaborator

@Hugal31 I believe this should be fixed in the most recent pre-release, could you try the most recent pre-release version?

@v-frankwang
Copy link
Collaborator

@gcampbell-msft @Hugal31 I verified on the latest pre-release version and the issue has been fixed.

ENV:
CMake Tools:v1.19.37(pre-release)
vscode:v1.92.0
C/C++:v1.21.6

Actual result:
3963

@Hugal31
Copy link
Author

Hugal31 commented Aug 8, 2024

I still have the issue using

  • CMake Tools v1.19.37 (pre-release)
  • VS code 1.92.0
  • C/C++ v1.21.6

Another way to reproduce is

  1. From a working setup, rename the included presets.json and change the "include" directive to make it work.
  2. Configure: the variables are good.
  3. Change a variable in the renamed presets.json: the preset is not reloaded.
  4. Configure: the variables are not changed.

@v-frankwang
Copy link
Collaborator

@Hugal31 Thank you very much for your reply! Would you be able to provide some screenshots or recordings so we can look into the issue?

@v-frankwang v-frankwang added more info needed More info is needed from the community for us to properly triage and investigate. and removed triage labels Aug 9, 2024
@Hugal31
Copy link
Author

Hugal31 commented Aug 9, 2024

Sure,

Here is a video and the minimal project. I tried with vscode 1.92.1

CMakeToolsBug.mp4

testcmaketools.tar.gz

EDIT: I can't make the video works on Github so here it is in a .gz:
CMakeToolsBug.mp4.gz

@v-frankwang
Copy link
Collaborator

@Hugal31 @moyo1997 We reproduced the problem using the project provided by the customer, after changing the filename of presets.json and the values of THE_OTHER_VAR and THE_VAR in the project, we ran the command CMake:Delete cache and reconfigure, the variables are not changed. If you resave the CMakePresets.json file after the variables are good.

ENV:

  • CMake Tools v1.19.38 (pre-release)
  • VS code 1.92.1
  • C/C++ v1.21.6

Actual result:
3963

@v-frankwang v-frankwang added bug a bug in the product and removed more info needed More info is needed from the community for us to properly triage and investigate. labels Aug 12, 2024
@qarni
Copy link
Contributor

qarni commented Aug 27, 2024

@Hugal31 I believe this is fixed in the latest pre-release!

@qarni qarni closed this as completed Aug 27, 2024
@github-project-automation github-project-automation bot moved this from Blocked to Completed in CMake Tools Aug 27, 2024
@Hugal31
Copy link
Author

Hugal31 commented Sep 2, 2024

I still have it with v1.20.3 (pre-release) on VScode 1.92.2 :/

@gcampbell-msft
Copy link
Collaborator

@Hugal31 @v-frankwang Could it be due to the fact that your file is named CMakepresets.json rather than CMakePresets.json?

@v-frankwang Could you test? Thanks. If not, please create a new issue with the details necessary for us to investigate. Thanks!

@Hugal31
Copy link
Author

Hugal31 commented Sep 3, 2024

@Hugal31 @v-frankwang Could it be due to the fact that your file is named CMakepresets.json rather than CMakePresets.json?

I don't know why that was the case, but in the .tar.gz I provided it's really CMakePresets.json and the bug is present.

@gcampbell-msft
Copy link
Collaborator

@Hugal31 Ah, re-reading your most recent repro steps, I think that the issue is due to the fact that we only create listeners for the files on startup. If you rename and save, in the current implementation, a reload will be needed. I'll reopen this and put it on our backlog.

@gcampbell-msft gcampbell-msft reopened this Sep 3, 2024
@gcampbell-msft gcampbell-msft moved this from Completed to Pending Prioritization in CMake Tools Sep 3, 2024
@gcampbell-msft gcampbell-msft added this to the Backlog milestone Sep 3, 2024
@github-actions github-actions bot added the triage label Sep 3, 2024
@Hugal31 Hugal31 changed the title Presets are not reloaded when an included file is changed untile reload Presets are not reloaded when an included file is changed until reloading the whole project Sep 4, 2024
@gcampbell-msft gcampbell-msft modified the milestones: Backlog, 1.20 Nov 5, 2024
@gcampbell-msft gcampbell-msft self-assigned this Nov 11, 2024
@github-project-automation github-project-automation bot moved this from Pending Prioritization to Completed in CMake Tools Nov 21, 2024
@Amy-Li03
Copy link
Collaborator

Verified this issue on the CMake Tools latest version: v1.20.27 (pre-release), it has been fixed. After renaming the included presets.json and changing a variable in the renamed presets.json which is not reloaded, the variables are good.

Image

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: presets
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

5 participants