Skip to content

Commit eb5a806

Browse files
authored
Reuse cmake.environment at init to avoid ENOENT errors (#2855) (#4414)
Especially when cmake is not defined in system PATH but cmake.environment setting. Signed-off-by: Julien Dehaudt <[email protected]>
1 parent e3c13ca commit eb5a806

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Bug Fixes:
2323
- Make tooltips for selecting Launch/Debug Target. [#4373](https://github.com/microsoft/vscode-cmake-tools/issues/4373)
2424
- Fix bug where unrelated symlinks are read as variant files [#4304](https://github.com/microsoft/vscode-cmake-tools/issues/4304) [@vitorramos](https://github.com/vitorramos).
2525
- Fix evaluation of conditions in presets. [#4425](https://github.com/microsoft/vscode-cmake-tools/issues/4425)
26+
- Fix ENOENT error at vscode startup on some circumstances [#2855](https://github.com/microsoft/vscode-cmake-tools/issues/2855) Contributed by STMicroelectronics
2627

2728
## 1.20.53
2829

src/cmakeExecutable.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as util from '@cmt/util';
33
import {setContextAndStore} from '@cmt/extension';
44
import * as logging from '@cmt/logging';
55
import * as nls from 'vscode-nls';
6+
import { ConfigurationReader } from './config';
67

78
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
89
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
@@ -24,7 +25,7 @@ export interface CMakeExecutable {
2425

2526
const cmakeInfo = new Map<string, CMakeExecutable>();
2627

27-
export async function getCMakeExecutableInformation(path: string): Promise<CMakeExecutable> {
28+
export async function getCMakeExecutableInformation(path: string, config?: ConfigurationReader): Promise<CMakeExecutable> {
2829
const cmake: CMakeExecutable = {
2930
path,
3031
isPresent: false,
@@ -50,7 +51,7 @@ export async function getCMakeExecutableInformation(path: string): Promise<CMake
5051
}
5152

5253
try {
53-
const execOpt: proc.ExecutionOptions = { showOutputOnError: true };
54+
const execOpt: proc.ExecutionOptions = { showOutputOnError: true, environment: config?.environment };
5455
const execVersion = await proc.execute(path, ['--version'], null, execOpt).result;
5556
if (execVersion.retc === 0 && execVersion.stdout) {
5657
console.assert(execVersion.stdout);

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class ExtensionManager implements vscode.Disposable {
146146
cmakePath = await workspaceContext.getCMakePath() || '';
147147
}
148148
// initialize the state of the cmake exe
149-
await getCMakeExecutableInformation(cmakePath);
149+
await getCMakeExecutableInformation(cmakePath, this.workspaceConfig);
150150

151151
await util.setContextValue("cmake:testExplorerIntegrationEnabled", this.workspaceConfig.testExplorerIntegrationEnabled);
152152
this.workspaceConfig.onChange("ctest", async (value) => {

0 commit comments

Comments
 (0)