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

Multi-root workspaces require all folders to a valid python interpreter #370

Closed
ngtrunghuan opened this issue Nov 7, 2023 · 4 comments
Closed
Assignees
Labels
triage-needed Issue is not triaged.

Comments

@ngtrunghuan
Copy link

ngtrunghuan commented Nov 7, 2023

When formatting a file in a folder with a valid interpreter, the extension failed due to the server not starting up. This seemed to be due to one of the folder not having a valid interpreter. The old black functionality under the ms-python.python extension however could function well.

Reproduction steps:

  • Enter a multi-root workspace, namely folder A and folder B
    • folder A has a valid interpreter setup
    • folder B doesn't (or has a < 3.8 interpreter)
  • Install ms-python.black
  • Run formatting using ms-python.black on a file in a folder that has a valid interpreter
  • See that
    1. black server failed to start
    2023-11-07 02:45:58.082 [info] No interpreter found from setting black-formatter.interpreter
    2023-11-07 02:45:58.082 [info] Getting interpreter from ms-python.python extension for workspace <MY OTHER FOLDER>
    2023-11-07 02:45:58.083 [error] Python version 3.7 is not supported.
    2023-11-07 02:45:58.083 [error] Selected python path: /usr/bin/python3
    2023-11-07 02:45:58.083 [error] Supported versions are 3.8 and above.
    2023-11-07 02:45:58.083 [info] No interpreter found for <MY FOLDER> in settings or from ms-python.python extension
    2023-11-07 02:45:58.084 [error] Python interpreter missing:
    [Option 1] Select python interpreter using the ms-python.python.
    [Option 2] Set an interpreter using "black-formatter.interpreter" setting.
    
    1. Formatting doesn't work
    2023-11-07 02:46:00.232 [info] Formatting requested before server has started.
    

ms-python.black version v2023.6.0
ms-python.python version v2023.21.13101009

@github-actions github-actions bot added the triage-needed Issue is not triaged. label Nov 7, 2023
@ngtrunghuan ngtrunghuan changed the title Multi-root workspaces require each folder to have an interpreter with black Multi-root workspaces require all folders to a valid python interpreter Nov 7, 2023
@karthiknadig
Copy link
Member

@ngtrunghuan You can set folder b to use the same interpreter as folder A. Just set the black-formatter.interpreter to the one used by folder A. you can use this to refer to folder A ${workspaceFolder}:A where A is the name of the folder A.

@karthiknadig karthiknadig self-assigned this Nov 7, 2023
@karthiknadig
Copy link
Member

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on then we will be happy to re-open this issue to pick up where we left off.

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2023
@stefanhige
Copy link

While the workaround with ${workspaceFolder:A} works, what if I have a multi-root workspace where the black formatter does not make sense for every folder (not every folder is a python project). Then I will have to define a python interpreter for every folder that is part of the multi-root workspace, just to make black formatter work for the one folder where I want to use it.

Could black formatter not only be available for those folders inside a multi-root workspace that provide all the necessary configuration?

@karthiknadig
Copy link
Member

@stefanhige You only need to do this if you have different python versions for each workspace root. I general if you have a "Entire Workspace" python, that will be used. You only ever deal with this problem if you explicitly have different pythons per workspace root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Issue is not triaged.
Projects
None yet
Development

No branches or pull requests

3 participants