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

PATH issue since v1.19 #4019

Closed
KorkiFork opened this issue Aug 29, 2024 · 23 comments · Fixed by #4024
Closed

PATH issue since v1.19 #4019

KorkiFork opened this issue Aug 29, 2024 · 23 comments · Fixed by #4024
Labels
bug a bug in the product more info needed More info is needed from the community for us to properly triage and investigate. regression used to work and no longer does. Regressions are typically high priority

Comments

@KorkiFork
Copy link

Brief Issue Summary

Hi!

Since CMake Tools version v1.19, the kits in the cmkae-tools-kits.json no longer read the system/user environment PATH correctly on Windows.
E.g. download Qt jom and add the jom.exe location to the system/user environment PATH.
Set a kit's preferredGenerator to "NMake Makefiles JOM", and when selecting the kit in a project configuration, the extension won't be able to find jom.exe.
Even adding path jom.exe via kit's environmentVariables won't help, e.g. environmentVariables{"PATH": "path_to_jom;${env.PATH}"}

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

@kimbirkelund
Copy link

I think I'm experiencing this too, but when setting the toolchain file - env var VCPKG_ROOT gets expanded to the empty string.

However it is expanded correctly inside my CMakeLists.txt file - message("VCPKG_ROOT: $ENV{VCPKG_ROOT}") prints expected value.

@PatrickKa
Copy link

I experienced the same problem with VCPKG_ROOT being expanded to the empty string when using v1.19 of this extension. Calling CMake from the command line still worked as expected. I tried some other environment variables, and they all got expanded to the empty string, so it seems like this is a general problem with v1.19.

@danny-mhlv
Copy link

Same here, VCPKG_ROOT environment variable is not being expanded.

"CMAKE_TOOLCHAIN_FILE": {
    "type": "FILEPATH",
    "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
},

CMake's output:

-DCMAKE_TOOLCHAIN_FILE:FILEPATH=/scripts/buildsystems/vcpkg.cmake

@marcogmaia
Copy link

Same here with

      "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"

In the CMakePresets.json

@Skyblade14
Copy link

same on my side. The bug cannot be that old...
i was on the pre release version and encountered the same issue on Tuesday, 2024-08-27.

@gcampbell-msft
Copy link
Collaborator

@Skyblade14 @marcogmaia @KorkiFork @danny-mhlv @PatrickKa @kimbirkelund Thank you all for quickly posting an issue! We just released the official 1.19 version yesterday, so it sounds like there may be a regression.

However, we can't necessarily properly investigate this without reproduction steps and repro projects. Could you all please provide these so that we can quickly investigate a fix?

@gcampbell-msft gcampbell-msft added bug a bug in the product more info needed More info is needed from the community for us to properly triage and investigate. regression used to work and no longer does. Regressions are typically high priority and removed triage labels Aug 29, 2024
@gcampbell-msft
Copy link
Collaborator

@Skyblade14 @marcogmaia @KorkiFork @danny-mhlv @PatrickKa @kimbirkelund I believe I've found the issue specifically for Presets, I haven't taken a look at kits yet. Could you install the below vsix and test to confirm? You'll need to modify the file extension from .zip to .vsix.
cmake-tools.zip

@PatrickKa
Copy link

It works 🎉. Environment variables in presets are now expanded correctly again. Thanks for the fast fix.

@gcampbell-msft
Copy link
Collaborator

Perfect, we will work to get a PR merged today and then a fix into pre-release as soon as possible.

@gcampbell-msft
Copy link
Collaborator

gcampbell-msft commented Aug 29, 2024

@KorkiFork I'm currently not able to reproduce the issue in the kits environment. I think the issue actually is related to this one #4020 and #4005, not an issue with the environment. I'll track this in the other issue.

@qarni qarni moved this from Blocked to In Progress in CMake Tools Aug 29, 2024
@gcampbell-msft
Copy link
Collaborator

@Skyblade14 @marcogmaia @KorkiFork @danny-mhlv @PatrickKa @kimbirkelund We have a PR open here #4024, once merged, it will go into pre-release the next morning.

@KorkiFork Please let me know if this fixes your issue, but since it's with kits, it may not. Please provide any more information about the error, the repro, etc, in order to help us reproduce your issue.

Thanks!

@danny-mhlv
Copy link

@gcampbell-msft huge thanks for your replies and work!

@github-project-automation github-project-automation bot moved this from In Progress to Completed in CMake Tools Aug 29, 2024
@KorkiFork
Copy link
Author

@Skyblade14 @marcogmaia @KorkiFork @danny-mhlv @PatrickKa @kimbirkelund We have a PR open here #4024, once merged, it will go into pre-release the next morning.

@KorkiFork Please let me know if this fixes your issue, but since it's with kits, it may not. Please provide any more information about the error, the repro, etc, in order to help us reproduce your issue.

Thanks!

Sorry for the late reply, but I had a busy day.
I tried the patch you provided (zip->vsx file you attached) and my issue still prevails.

@KorkiFork
Copy link
Author

KorkiFork commented Aug 29, 2024

Reproduce issue like this:
Install jom (https://wiki.qt.io/Jom).
Add jom.exe location to your system PATH.
In cmake-tools-kits.json add the following kit:
{"name": "JOM test kit", "preferredGenerator": {"name": "NMake Makefiles JOM"}}

Open a CMake project and try to configure it with the "JOM test kit".
You will get the error:

[main] Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit configuration or PATH variable. Error: No usable generator found.

@gcampbell-msft
Copy link
Collaborator

@KorkiFork Got it. I'll get to this issue and try to repro it as soon as possible.

@gcampbell-msft
Copy link
Collaborator

@KorkiFork To workaround this, can you set the cmake.generator in your workspace to the desired generator?

@KorkiFork
Copy link
Author

KorkiFork commented Aug 30, 2024

@KorkiFork To workaround this, can you set the cmake.generator in your workspace to the desired generator?

Tested with v1.20.1 (pre-release), setting cmake.generator in settings.json, the issue is still present.

@marcogmaia
Copy link

marcogmaia commented Aug 30, 2024

@gcampbell-msft, I can confirm the same results as @KorkiFork, I've tested with the v1.20.1 (pre-release) and the extension isn't honoring the VS devenv.

@gcampbell-msft
Copy link
Collaborator

gcampbell-msft commented Aug 30, 2024

@marcogmaia What is your scenario? I can't repro or investigate your issues without reproduction steps and more info.

We tested pretty thoroughly the use of VS devenv in Presets, so are you using Kits?

@marcogmaia
Copy link

@gcampbell-msft I've described what's happening with me in #4031.

@vipcxj
Copy link

vipcxj commented Dec 25, 2024

It seems that the bug comes back, #4218
I was using the latest cmake tool which is 1.19.52

@gcampbell-msft
Copy link
Collaborator

@vipcxj Does this issue reproduce on the most recent pre-release version?

@KorkiFork
Copy link
Author

On version 1.20.42 the issue seems to be resolved by the CMake Extension in VS Code.
I see that you provide the variables set in a kit's cmakeSettings as command line arguments to CMake.
But CMake doesn't seem to handle the provided variables correctly. E.g. if in cmakeSettings the environment variable PATH is extended with an additional directory, this updated PATH value will be provided to CMake via the command line, but CMake ignores it and uses the original system PATH value.

But I guess this is our of scope for this conversation and should be reported to the CMake project, if it is considered to be a bug.

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 more info needed More info is needed from the community for us to properly triage and investigate. regression used to work and no longer does. Regressions are typically high priority
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

9 participants