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

Support userHome and other env variables in settings #24673

Open
nickeldan opened this issue Jan 3, 2025 · 2 comments
Open

Support userHome and other env variables in settings #24673

nickeldan opened this issue Jan 3, 2025 · 2 comments
Labels
feature-request Request for new features or functionality needs community feedback Awaiting community feedback

Comments

@nickeldan
Copy link

Type: Bug

The extension cannot resolve the path to my Python interpreter (which I've confirmed exists). In my workspace's settings.json file, I have

"python.defaultInterpreterPath": "${userHome}/path/to/python3"

However, Python's output shows

[error] Error initializing python: [l [Error]: Failed to resolve env "/path/to/project/${userHome}/path/to/python3"

Extension version: 2024.22.1
VS Code version: Code 1.96.2 (Universal) (fabdb6a30b49f79a7aba0f2ad9df9b399473380f, 2024-12-19T10:22:47.216Z)
OS version: Darwin x64 24.2.0
Modes:
Remote OS version: Linux x64 6.8.0-51-generic

A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt551:31179978
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
vscaac:30438847
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupyter:31046869
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc1:31192215
cf971741:31144450
iacca1:31171482
notype1:31157159
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jan 3, 2025
@karthiknadig
Copy link
Member

userHome is environment variable and is not supported in this scenario. Note that VS Code itself does not support these variables in settings, it is only supported in launch.json, and tasks.json.

Python extension handles env variables in some cases like in .env files. There are also system variables, like workspace folder, selected file, selected text etc, those are also handled in some cases not all.

public get cwd(): string {
return this.workspaceFolder;
}
public get workspaceRoot(): string {
return this._workspaceFolder;
}
public get workspaceFolder(): string {
return this._workspaceFolder;
}
public get workspaceRootFolderName(): string {
return this._workspaceFolderName;
}
public get workspaceFolderBasename(): string {
return this._workspaceFolderName;
}
public get file(): string | undefined {
return this._filePath;
}
public get relativeFile(): string | undefined {
return this.file ? Path.relative(this._workspaceFolder, this.file) : undefined;
}
public get relativeFileDirname(): string | undefined {
return this.relativeFile ? Path.dirname(this.relativeFile) : undefined;
}
public get fileBasename(): string | undefined {
return this.file ? Path.basename(this.file) : undefined;
}
public get fileBasenameNoExtension(): string | undefined {
return this.file ? Path.parse(this.file).name : undefined;
}
public get fileDirname(): string | undefined {
return this.file ? Path.dirname(this.file) : undefined;
}
public get fileExtname(): string | undefined {
return this.file ? Path.extname(this.file) : undefined;
}
public get lineNumber(): number | undefined {
return this._lineNumber;
}
public get selectedText(): string | undefined {
return this._selectedText;
}
public get execPath(): string {
return this._execPath;
}

@karthiknadig karthiknadig changed the title userHome not resolved Support userHome and other env variables in settings Jan 14, 2025
@karthiknadig karthiknadig removed their assignment Jan 14, 2025
@karthiknadig karthiknadig added feature-request Request for new features or functionality needs community feedback Awaiting community feedback and removed triage-needed Needs assignment to the proper sub-team labels Jan 14, 2025
Copy link

Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality needs community feedback Awaiting community feedback
Projects
None yet
Development

No branches or pull requests

2 participants