microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.7k stars 768 forks source link

Pylance crashes upon startup: `[info] Error: [UriError]: Scheme contains illegal characters.` #5032

Closed darynwhite closed 10 months ago

darynwhite commented 10 months ago

Environment data

Code Snippet

See log file below.

Here are the last lines:

2023-10-27 14:28:53.592 [info] Error: [UriError]: Scheme contains illegal characters.
    at l (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/vendor.bundle.js:2:1390846)
    at t (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/vendor.bundle.js:2:1391782)
    at new t (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/vendor.bundle.js:2:1393374)
    at Function.t.parse (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/vendor.bundle.js:2:1392677)
    at v (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1099841)
    at w (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1101719)
    at A (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1101778)
    at /Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1481891
    at Array.filter (<anonymous>)
    at o.readdirEntriesSync (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1481843)
    at _0x1c8f27.readdirEntriesSync (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/server.bundle.js:1:216408)
    at c (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:456960)
    at I.ensureDefaultExtraPaths (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1064461)
    at k._getConfigOptions (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:472865)
    at k.setOptions (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:466884)
    at Function.runWithOptions (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1165682)
    at _0x42211f.updateOptionsAndRestartService (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1143168)
    at _0x42211f.updateSettingsForWorkspace (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/pyright.bundle.js:1:1142935)
    at _0x42211f.updateSettingsForWorkspace (/Users/white/.vscode/extensions/ms-python.vscode-pylance-2023.10.53/dist/server.bundle.js:1:875505)
    at async Promise.all (index 0)

2023-10-27 14:28:53.598 [info] [Error - 2:28:53 PM] Server process exited with code 1.
2023-10-27 14:28:53.599 [info] [Error - 2:28:53 PM] The Pylance server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

Repro Steps

This is happening on startup, no matter how I start up.

To answer the questions from #5009:

Logs

Python Language Server.log

seramakiera commented 10 months ago

I am having the same issue.

darynwhite commented 10 months ago

Rolling back to version 2023.10.40 fixes it

debonte commented 10 months ago

@darynwhite, @DmitryKharitonov, can either of you reproduce this in a public repo or code that can be shared, perhaps privately?

If not, I'm curious what you have python.analysis.extraPaths set to. That might give me a clue.

seramakiera commented 10 months ago

@debonte - I want to help but I just don't know where this setting should be.

I created another repo with a test project, but Pylance seems to be working there just fine. This is my current repo - see if it helps: public repo

This is settings.json:

{
    "git.enableSmartCommit": true,
    "explorer.confirmDelete": false,
    "python.pythonPath": "/usr/bin/python3",
    "git.autofetch": true,
    "npm.keybindingsChangedWarningShown": true,
    "notebook.output.textLineLimit": 50,
    "[python]": {
        "editor.formatOnType": true
    },
    "notebook.lineNumbers": "on",
    "git.confirmSync": false,
    "codegpt.apiKey": "sxxx",
    "codegpt.model": "ChatGPT",
    "CodeGPT.organizationId": "xxx",
    "CodeGPT.windowMemory": 10,
    "python.analysis.diagnosticSeverityOverrides": {},
    "python.autoComplete.extraPaths": [],
    "python.analysis.extraPaths": []
}

Also, copied 2 additional lines above the error to add more colour in hope it would be helpful to investigate. Scroll to the right until you see character "^"

2023-10-28 09:25:03.292 [info]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
2023-10-28 09:25:03.294 [info]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ^
Error: [UriError]: Scheme contains illegal characters.
    at l (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/vendor.bundle.js:2:1628554)
    at t (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/vendor.bundle.js:2:1629490)
    at new t (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/vendor.bundle.js:2:1631082)
    at Function.t.parse (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/vendor.bundle.js:2:1630385)
    at v (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:1097933)
    at w (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:1099765)
    at A (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:1099824)
    at o.processPartialStubPackages (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:1477412)
    at _0x4db351.processPartialStubPackages (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/server.bundle.js:1:340620)
    at _0xa6e677.ensurePartialStubPackages (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:293366)
    at _0x39eed6._ensurePartialStubPackages (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:8537)
    at /Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:5290
    at Array.forEach (<anonymous>)
    at _0x39eed6.setImportResolver (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:5273)
    at k._applyConfigOptions (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:488754)
    at k.setOptions (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:466191)
    at Function.runWithOptions (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:1163681)
    at _0x5e13d0.updateOptionsAndRestartService (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:1141163)
    at _0x5e13d0.updateSettingsForWorkspace (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/pyright.bundle.js:1:1140930)
    at _0x5e13d0.updateSettingsForWorkspace (/Users/dmitriikharitonov/.vscode/extensions/ms-python.vscode-pylance-2023.10.50/dist/server.bundle.js:1:1018272)
    at async Promise.all (index 0)

2023-10-28 09:25:03.353 [info] [Error - 09:25:03] Server process exited with code 1.
2023-10-28 09:25:03.359 [info] [Error - 09:25:03] The Pylance server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
BozeBro commented 10 months ago

Am having the same issue as well. I didn't do anything special. For me, on Neovim

debonte commented 10 months ago

@DmitryKharitonov, thanks for sharing your repo! I was able to reproduce the crash. It's a bug in our URI-related logic. Your repo contains a directory named Supervised Machine Learning: Regression and Classification and we're incorrectly assuming that because it contains a : it is a URI. We then attempt to parse it as a URI which causes the exception.

We'll prioritize fixing this, but in the meantime you should be able to work around the crash by removing the : from this directory name.

@darynwhite, @BozeBro, when you see this crash are you also opening workspaces containing directories whose names contain a : character?

Repro:

  1. Create a new folder on a Linux/Mac machine. I used WSL.
  2. Add subdirectory named Supervised Machine Learning: Regression and Classification
  3. Add Python file in subdir.
  4. Open dir from step 1 in VS Code.
  5. Open Python file in subdir.
darynwhite commented 10 months ago

... can either of you reproduce this in a public repo or code that can be shared, perhaps privately?

I was able to reproduce it with this repo: darynwhite/wagtail-feedstock

If not, I'm curious what you have python.analysis.extraPaths set to. That might give me a clue.

I have no extra paths set, and have disabled and re-enabled all custom settings a few times.

when you see this crash are you also opening workspaces containing directories whose names contain a : character?

I have no directories or filenames containing the : character, but there are - and _ if they could be causing a problem?

debonte commented 10 months ago

@darynwhite, I'm unable to reproduce the crash with your repo. The UI detection problem that I found is specific to the : character. My best guess is that there's a : in one of the directory names in your venv or global environment.

darynwhite commented 10 months ago

Thanks @debonte, I'll look for : specifically.

silencewing commented 10 months ago

Rolling back to version 2023.10.40 fixes it

it's work!

bschnurr commented 10 months ago

This issue has been fixed in prerelease version 2023.11.11, which we've just released. You can find the changelog here: CHANGELOG.md