microsoft / microsoft/vscode-cmake-tools

`${command:python.interpreterPath}` fails when used as a parameter to `cmake.configureSettings`

Open
#3,648 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Feature: settings more votes needed
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

Brief Issue Summary

In my .vscode configuration:

  "cmake.configureSettings": {
    // "PYTHON_EXECUTABLE": "/Users/ncohen/Library/Caches/pypoetry/virtualenvs/zephyrus--PefSXhl-py3.10/bin/python"
    "PYTHON_EXECUTABLE": "${command:python.interpreterPath}"
  }

The first one commented line above works as intended and induces the configured build to detect the desired (manually set) python environment.

I would like to use the second form so that the build automatically uses vscode's current active selected python interpreter. This is supposed to be supported I think -- at least according to [these docs](https://vector-of-bool.github.io/docs/vscode-cmake-tools/settings.html#command-substitution.

However this fails with:

[main] Configuring project: zephyrus 
[expand] Exception while executing command python.interpreterPath for string: -DPYTHON_EXECUTABLE:STRING=${command:python.interpreterPath} 
	TypeError: Cannot use 'in' operator to search for 'workspaceFolder' in /Users/ncohen/software/zephr/zephyrus
	at d._getSelectedInterpreterPath (/Users/ncohen/.vscode/extensions/ms-python.python-2024.2.1/out/client/extension.js:2:447857)
	at /Users/ncohen/.vscode/extensions/ms-python.python-2024.2.1/out/client/extension.js:2:447750
	at l.h (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:184839)
	at l.g (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:183831)
	at l.executeCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:183738)
	at Object.executeCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:160:21654)
	at expandStringHelper (/Users/ncohen/.vscode/extensions/ms-vscode.cmake-tools-1.17.17/dist/main.js:56487:50)
	at Object.expandString (/Users/ncohen/.vscode/extensions/ms-vscode.cmake-tools-1.17.17/dist/main.js:56375:37)
	at /Users/ncohen/.vscode/extensions/ms-vscode.cmake-tools-1.17.17/dist/main.js:53919:81
	at Array.map (<anonymous>)
	at CMakeFileApiDriver.generateConfigArgsFromSettings (/Users/ncohen/.vscode/extensions/ms-vscode.cmake-tools-1.17.17/dist/main.js:53919:53)
	at async CMakeFileApiDriver.configure (/Users/ncohen/.vscode/extensions/ms-vscode.cmake-tools-1.17.17/dist/main.js:53971:34)
	at async /Users/ncohen/.vscode/extensions/ms-vscode.cmake-tools-1.17.17/dist/main.js:44850:50
	at async CMakeProject.doConfigure (/Users/ncohen/.vscode/extensions/ms-vscode.cmake-tools-1.17.17/dist/main.js:45001:24)
[proc] Executing command: /opt/homebrew/bin/cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DPYTHON_EXECUTABLE:STRING=${command:python.interpreterPath} -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -S/Users/ncohen/software/zephr/zephyrus -B/Users/ncohen/software/zephr/zephyrus/build -G Ninja
CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the configuration in the .vscode settings and start at expandStringHelper and CMakeFileApiDriver.generateConfigArgsFromSettings in dist/main.js, alongside the Python command python.interpreterPath. Trace the command-substitution call and compare it with the documented behavior; done means the selected interpreter is passed as PYTHON_EXECUTABLE without the reported exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, python, typescript, vscode
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.