Skip to content

multiroot-workspace-wide "pythonPath" setting is not respected through all folders if it's a relative path #15610

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

Closed
schperplata opened this issue Mar 9, 2021 · 5 comments
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug

Comments

@schperplata
Copy link

I have one VSC workspace with multiple folders. There is no settings.json or .vscode folder(s), just a single .code-workspace file with all settings, launch and other workspace settings. Here is my folder structure:

  • folder1/:
    • <package 1>/
    • wks/:
      • dev.code-workspace
      • venv/
  • folder2/:
    • <package 2>/
  • folder3/:
    • <package 3>/
      ...

I want to use venv from folder1 in all folders/packages added to dev.code-workspace, so I set workspace-wide python interpretter setting to python in venv. As it currently works, venv is detected, selected and activated properly for folder1, but not for others. Others report missing python interpretter path setting and therefore also doesn't work.
Am I doing something wrong or is this a bug?

Originally posted by @schperplata in #3325 (comment)

@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Mar 9, 2021
@OmeGak
Copy link

OmeGak commented Mar 9, 2021

I'm experiencing the same situation. My workaround was to explicitly configure python.pythonPath for folder2/ in folder2/.vscode/settings.json:

{
    "python.pythonPath": "../venv/bin/python",
}

@karthiknadig karthiknadig added area-environments Features relating to handling interpreter environments triage bug Issue identified by VS Code Team member as probable bug labels Mar 9, 2021
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Mar 9, 2021
@kimadeline kimadeline changed the title workspace-wide "pythonPath" setting is not respected through all folders multiroot-workspace-wide "pythonPath" setting is not respected through all folders Mar 9, 2021
@kimadeline
Copy link

Hi @schperplata, thank you for making a separate issue for your problem!

I cannot replicate the issue you're having: I specified the absolute path to my virtual environment in the .code-workspace file and all folders see it:

multiroot.code-workspace:

{
	"folders": [
		{
			"path": "./folder1"
		},
		{
			"path": "./folder2"
		},
		{
			"path": "./folder3"
		},
		{
			"path": "folder1/folder4"
		}
	],
	"settings": {
		"python.formatting.provider": "black",
		"editor.formatOnSave": true,
		"python.terminal.activateEnvInCurrentTerminal": true,
		"python.pythonPath": "~/Documents/Sandbox/multiroot/folder1/.venvone/bin/python"
	}
}

and my folder structure:

image

Could you post the content of the Python channel from the Output panel here?

@schperplata
Copy link
Author

@kimadeline I (we) do not work with absolute paths. Workspace is a part of a versioned folder structure and therefore path must be relative.
Until this is resolved, I configured venv so that it is created in a location that we all have (all users of this VSC workspace) and than set path via system environment variable, which is a hack and makes problem elsewhere (for example, system env variables are still not supported in code-workspace files).
Anyway, for us, relative paths are the only option which VSCode doesn't properly resolve. I would assume that if path is configured in code-workspace file and added folders do not have its own code-workspace or settings files, this relative path is always resolved to the location of code-workspace file?

@kimadeline kimadeline changed the title multiroot-workspace-wide "pythonPath" setting is not respected through all folders multiroot-workspace-wide "pythonPath" setting is not respected through all folders if it's a relative path Mar 10, 2021
@kimadeline
Copy link

Thank you for the clarification! We do have a lot of room for improvement for multiroot workspace support. I marked this issue as preexisting since it's not anything new that was introduced in a recent release.

@kimadeline kimadeline added needs PR and removed triage labels Apr 6, 2021
@kimadeline kimadeline removed their assignment Apr 6, 2021
@karrtikr
Copy link

karrtikr commented Jun 7, 2022

Closing in favor of #18650, relative paths are no longer needed.

@karrtikr karrtikr closed this as completed Jun 7, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

5 participants