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

No symbols found in Outline when in a multi-root workspace #1854

Closed
memeplex opened this issue Sep 11, 2019 · 14 comments
Closed

No symbols found in Outline when in a multi-root workspace #1854

memeplex opened this issue Sep 11, 2019 · 14 comments
Assignees
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@memeplex
Copy link

I've reported the following bug to the MS-PLS tracker:

microsoft/python-language-server#1536

But maybe it belongs here. I let you decide.

Environment data

  • VS Code version: 1.38.0
  • Extension version: 2019.9.34911
  • OS and version: Ubuntu 19.04
  • Python version: 3.7.3
  • Type of virtual environment used: N/A
  • Relevant/affected Python packages and their versions: XXX
  • Jedi or Language Server? Language Server

Expected behaviour

See link above.

Actual behaviour

See link above.

Steps to reproduce:

  1. Create a workspace
  2. Add a number of folders containing python projects
  3. Open some file for each of the projects
  4. See if outline is ok for every open file
  5. Restart vscode and check again
  6. Close and restart vscode with different active editors each time and check again

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

User belongs to experiment group 'ShowExtensionSurveyPrompt - control'
> conda --version
> pyenv root
> python3.7 -c "import sys;print(sys.executable)"
> python3.6 -c "import sys;print(sys.executable)"
> python3 -c "import sys;print(sys.executable)"
> python2 -c "import sys;print(sys.executable)"
> python -c "import sys;print(sys.executable)"
> /usr/bin/python3 -c "import sys;print(sys.executable)"
> conda info --json
> /usr/bin/python ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python2 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python2 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python2.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python2.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python3.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python3.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python2 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python2 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python2.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python2.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python3 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python3 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python3.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python3.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python2 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python2 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python2.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python2.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python3.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /usr/bin/python3.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python2 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python2 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python2.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python2.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python3 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python3 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python3.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
> /bin/python3.7 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/interpreterInfo.py
Starting Jedi Python language engine.
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
    for cls in suite._tests:
        try:
            for m in cls._tests:
                print(m.id())
        except:
            pass"
cwd: ~/Projects/Jampp/Gcd
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
    for cls in suite._tests:
        try:
            for m in cls._tests:
                print(m.id())
        except:
            pass"
cwd: ~/Projects/Jampp/Gcd
> conda info --json
> conda --version
> /usr/bin/python3 -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s ~/Projects/Jampp/Gcd/setup.py
cwd: ~/Projects/Jampp/Gcd
> /usr/bin/python3 -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s ~/Projects/Jampp/Gcd/setup.py
cwd: ~/Projects/Jampp/Gcd
##########Linting Output - flake8##########
> /usr/bin/python3 -c "import sys;print(sys.prefix)"
cwd: ~/Projects/Jampp/Gcd
> /usr/bin/python3 -c "import sys;print(sys.prefix)"
cwd: ~/Projects/Jampp/Gcd
> /usr/bin/python3 -c "import sys;print(sys.executable)"
cwd: ~/Projects/Jampp/Gcd
> /usr/bin/python3 -c "import sys;print(sys.executable)"
cwd: ~/Projects/Jampp/Gcd
> /usr/bin/python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: ~/Projects/Jampp/Gcd
> /usr/bin/python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: ~/Projects/Jampp/Gcd
> /usr/bin/python3 -m site --user-site
cwd: ~/Projects/Jampp/Gcd
> /usr/bin/python3 -m site --user-site
cwd: ~/Projects/Jampp/Gcd
> /usr/bin/python3 completion.py
cwd: ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles
> /usr/bin/python3 completion.py
cwd: ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles
@memeplex
Copy link
Author

Ok, as commented in microsoft/python-language-server#1536 (comment), this seems to be a bug in vscode-python. A serious bug I would say because it kinda means that multi-root workspaces are not supported with the language server (?).

@luabud
Copy link
Member

luabud commented Sep 12, 2019

Related to microsoft/vscode-python#5132, if not dup

@memeplex
Copy link
Author

I think it's a dup but it's not making clear that it's strictly pls (not jedi) related and also it's a bit confusing by the fact it somehow relates the issue to venvs, which AFAICS have nothing to do with the problem (I'm not running inside a venv now and I can perfectly reproduce the issue).

@DonJayamanne
Copy link
Collaborator

  • Please could you provide more information on what is working and what isn't.
  • Please provide some sample code, screen shots.
    I'd like to try to remote this at our end, without that it's difficult to tell what's working and what holes you have opened.
    If possible provide a fit repo and a set of instructions to replicate the issue.
  • Are you opening files that don't belong to any of the 3 workspace folders? Or do they all belong to one of the three folders?

@memeplex
Copy link
Author

memeplex commented Sep 12, 2019

@DonJayamanne as for your first point, some things I could say aren't working are: empty outline for some files and also no ctrl-click style navigation for identifiers (as noted before, this happens for all files in a project or for no file in a project, and the failing projects vary from launch to launch, I think according to the first active editor but I can tell that for sure, it feels a bit random, but the first file always get an outline, for example). Regarding your third point, I'm not, all open files belong to one of the project folders. But the workspace settings file itself is in another directory, not in the same root containing the project folders. Regarding the second, I can't share the projects in my workspace but I will try to reproduce the issue in a minimal setting and send that to you; you will have to wait a few days though, since I'm very busy right now.

Please read also the comments they made in microsoft/python-language-server#1536.

@DonJayamanne
Copy link
Collaborator

Regarding the second, I can't share the projects in my workspace but I will try to reproduce the issue in a minimal setting and send that to you; you will have to wait a few days though, since I'm very busy right now.

Thanks for your patience. Will wait for your sample repo.

In it future, please could you got the issue in one repo.
Right now, we (both teams are looking at this issue), and we don't know where the issue is. I.re. were doubling the effort.

@memeplex
Copy link
Author

were doubling the effort.

It wasn't my intention, I let you both know that the issue was opened in both repositories, I thought it was better left to you to close one of them, but maybe it's preferable that you simply move issues between your repos, if that's possible.

Here you have a minimal example. It contains a two folder workspace. I have a configured a virtual environment in the venv folder, you will have to configure "python.pythonPath" accordingly, and maybe "python.venvPath". Then open both mod1.py and mod2.py. Run code when mod1.py was the last active tab before closing it, then switch to mod2.py and you should have no outline information. Similarly swapping mod1.py and mod2.py.

vstest.zip

@memeplex
Copy link
Author

@DonJayamanne please let me know if you need more info in order to reproduce the issue, since I still see the info-needed label.

@DonJayamanne DonJayamanne removed their assignment Sep 30, 2019
@karthiknadig karthiknadig self-assigned this Oct 1, 2019
@karthiknadig karthiknadig removed their assignment May 13, 2020
@Allerka
Copy link

Allerka commented Aug 20, 2020

I'm experiencing this issue too. I usually have multiple folders from a common root folder loaded into VS Code (as I frequently bounce between projects), and I've noticed the Outline function for Python files never works, usually just saying "The active editor cannot provide outline information" (very rarely saying no symbols were found in the file). Normally I run the extension remotely, but I've also tested this with it loaded locally, and accessing files locally and remotely, and at best the first Python file I open gets an outline, and the rest don't. I've also checked multiple other languages (JS, JSON, CSS, etc.) on both local and remote, and none of them have any trouble with the outline. As soon as I remove all but one folder from the workspace, the outline fires up fine. Trying to restart the language server (or reloading the window for that matter) has zero effect while multiple folders are open.

I've noticed in the output window for Python, it gives me several different errors when multiple folders are open:

  • It can't find an active interpreter (I'm not sure why I have to keep re-specifying it after a reload when it doesn't change. Sometimes I have to reload the window again to get it to actually acknowledge the interpreter), even if one's shown as active at the bottom of the screen (i.e. the error pops up again when I open a new file).
  • It can't find settings.json (because it's looking in the wrong folder, such as in /project/.config/Code/User/settings.json instead of /project/.vscode/settings.json or /root/.vscode/settings.json, or it's using the wrong kind of slashes).
  • Or it can't find Python at all (only seems to happen if the extension is run locally).

The Language Server output remains blank as long as I've got multiple folders open.

Here's my setup info for reference:

  • VS Code version: 1.48.0
  • Extension version: 2020.8.101144 (Also tested with 2020.7.96456
  • OS and version: Local, Windows 10, remote: Ubuntu 16.04
  • Python version: Local, 3.8.1, remote: 3.5.2, 3.7.4, 3.8.2 (tested with all versions)
  • Type of virtual environment used: N/A
  • Relevant/affected Python packages and their versions: N/A (I think)
  • Jedi or Language Server? Language Server

Any insight would be appreciated. I'd prefer to not have to keep four copies of VS Code open most of the time. Thanks!

EDIT: I forgot to add, if I switch from the MS language server to Jedi, it still doesn't work, and I start getting error messages about "Failed to initialize experiments" or "Failed to download and store experiments".

@aarwurzer2
Copy link

The issue is still persisting.

Having the same setup as described by @Allerka and @memeplex (albeit on newer versions of both VS Code and the extension, and using different OS). The issue starts as soon as you're adding a folder to the Workspace with the option File | Add Folder to Workspace....

So it's not just 'having different folders open', but it's really tied to the Workspace. As long as the Workspace is tied to one 'root' folder, there's no issue. Outline works correctly as can be verified by the using the command Go to Symbol in Editor or Go to Symbol in Workspace.

As soon as you add another folder to your Workspace with the option File | Add Folder to Workspace... - and thus effectively creating multi-root Workspace - the Outline doesn't work anymore. The command Go to Symbol in Editor will now display The active editor does not provide symbol information (and thus the reason that Outline info is not working, would be my guess). Removing the folder from the Workspace (and relaunching VS Code) again solves the issue.

The issue seems to be related to the Python extension, as the issue is not present with e.g. Markdown files.

My setup:

  • OS: Local, Windows 10 x64 10.0.21390 (system setup)
  • VS Code: Local, 1.56.2 (system setup)
  • Python Extension: ms-python.python 2021.5.842923320
  • Pylance Extension: ms-python.vscode-pylance 2021.6.0
  • Jupyter Extension: ms-toolsai.jupyter 2021.6.832593372
  • Using Language Server (Microsoft)

Any other useful info I should mention?

@karthiknadig
Copy link
Member

This is addressed with language server setting as JediLSP, but not in Pylance. In pylance already opened files don't get Outlines, but switching tabs and back seems to get the Outlines.

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Sep 21, 2021
@jakebailey
Copy link
Member

I guess this too is #1823, but again, we don't even receive the request when this happens. This can't be a Pylance problem, this is a client problem.

@jakebailey
Copy link
Member

jakebailey commented Sep 21, 2021

Hm, no, this may be slightly different, relating to adding workspaces?

@aarwurzer2 @karthiknadig Do any features work when you do the above? Or is it only the outline that is broken?

@jakebailey jakebailey reopened this Sep 21, 2021
@jakebailey jakebailey added the waiting for user response Requires more information from user label Sep 21, 2021
@github-actions github-actions bot removed the triage label Sep 21, 2021
@jakebailey jakebailey added needs investigation Could be an issue - needs investigation and removed waiting for user response Requires more information from user labels Oct 20, 2021
@github-actions github-actions bot added triage and removed triage labels Oct 20, 2021
@heejaechang heejaechang self-assigned this Apr 12, 2022
@heejaechang
Copy link
Contributor

it doesn't repro. I can see outlining for files under multi workspace root in the latest pylance.

@heejaechang heejaechang added fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed needs investigation Could be an issue - needs investigation labels Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

8 participants