Closed jobinnthomas closed 1 week ago
Apologies, I have not tried the instructions for older VSCode versions in a while and it looks like they are quite out of date. :man_facepalming:
Picking up from here
I am stuck after this...the instructions there after say the following:
Open .vscode/extensions/vscode-playground/ directory in VS Code
Open the root of the pygls repository in VSCode
Add a settings file examples/servers/.vscode/settings.json
with the following contents
{
"pygls.server.cwd": "${workspaceFolder}",
"pygls.server.launchScript": "code_actions.py",
"pygls.server.pythonPath": "c:\\Path\\to\\venv\\Scripts\\python.exe",
"pygls.client.documentSelector": [
{
"scheme": "file",
"language": "plaintext"
}
]
}
of course, replacing "c:\\Path\\to\\venv\\Scripts\\python.exe"
with the path to the environment in which you installed the pygls library.
Open the Run and Debug view (Ctrl+Shift+D)
In this dropdown
There should be an option called pygls: Debug Client
, make sure it is selected and then hit F5
/click the green play button.
It should hopefully, open a second VSCode window with the pygls-playground extension enabled and the workspace should contain all our example servers, demo files and the settings file you created in step 2.
Finally, you should be able to open the sums.txt
file and be able to use VSCode's light bulbs to solve the simple sums in that file.
Hope that helps!
Thank you for the care in the instructions. I appreciate your effort.
I got these errors in my main vscode when i ran pygls: Debug Client as you suggested.
rejected promise not handled within 1 second: Error: Please set a working directory via the `pygls.server.cwd` setting
stack trace: Error: Please set a working directory via the `pygls.server.cwd` setting
at getCwd (h:\SoftwareQA\sandbox\jobin\pygls\.vscode\extensions\pygls-playground\src\extension.ts:280:15)
at startLangServer (h:\SoftwareQA\sandbox\jobin\pygls\.vscode\extensions\pygls-playground\src\extension.ts:147:17)
at h:\SoftwareQA\sandbox\jobin\pygls\.vscode\extensions\pygls-playground\src\extension.ts:93:27
at w.value (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:160:19733)
at n.y (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1902)
at n.z (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1972)
at n.fire (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:2188)
at w.value (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:77365)
at n.y (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1902)
at n.fire (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:2119)
at i.acceptDocumentsAndEditorsDelta (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:152:25348)
at i.$acceptDocumentsAndEditorsDelta (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:152:23856)
at s.S (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:147:5519)
at s.Q (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:147:5285)
at s.M (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:147:4375)
at s.L (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:147:3454)
at w.value (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:147:2241)
at n.y (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1902)
at n.fire (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:2119)
at r.fire (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:105:14091)
at w.value (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:173:8050)
at n.y (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1902)
at n.fire (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:2119)
at r.fire (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:105:14091)
at MessagePortMain.<anonymous> (c:\VSCode\VSCode-win32-x64-1.87.2 (1)\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:173:6330)
at MessagePortMain.emit (node:events:514:28)
at Object.emit (node:electron/js2c/utility_init:2:2285)
at Object.callbackTrampoline (node:internal/async_hooks:130:17)
It did open up a new window and in this extension VSCode window, i see this in Output:
2024-08-26 11:26:31.298 [info] Extension activated. 2024-08-26 11:26:32.025 [error] Please set a working directory via the
pygls.server.cwd
setting
My settings.json does have pygls.server.cwd set. It looks like this:
"[plaintext]": {
// Uncomment to enable `textDocument/onTypeFormatting` requests
// "editor.formatOnType": true
},
// Uncomment to override Python interpreter used.
"pygls.server.pythonPath": "H:\\SoftwareQA\\sandbox\\jobin\\env\\Scripts\\python.exe",
"pygls.server.debug": true,
"pygls.server.debugHost": "localhost",
"pygls.server.debugPort": 5658,
"pygls.server.launchScript": "code_actions.py", // This is relative to `pygls.server.cwd`
"pygls.server.cwd": "H:\\SoftwareQA\\sandbox\\jobin\\pygls\\examples\\servers",
"pygls.trace.server": "verbose",
"pygls.client.documentSelector": [
{
"scheme": "file",
"language": "plaintext"
}
],
// "pygls.jsonServer.exampleConfiguration": "some value here",
When i try to pygls: Debug Server, I get below. Is the server getting started in this process when i run the Debug:Client?
I can also see that pygls is installed..but these statements here seem to be dim for some reason only "[plaintext]": is highlighted ....is that expected?
confirming pygls
I debugged it . It seems to be erroring out here as shown below. I havent worked on typescript much. It looks like its not able to access the settings.json configuration. Any ideas why?
On another point, is there any other requirement than pygls package in python, Vscode with python extension, latest npm installed, is there any other requirement?
Is there any particular port requirements for server. I am wondering if my work antivirus or firewall will block something
I can also see that pygls is installed..but these statements here seem to be dim for some reason only "[plaintext]": is highlighted ....is that expected?
The options being dim is showing that the pygls-playground
extension is not loaded in that VSCode window.
I got these errors in my main vscode when i ran pygls: Debug Client as you suggested.
rejected promise not handled within 1 second: Error: Please set a working directory via the `pygls.server.cwd` setting stack trace: Error: Please set a working directory via the `pygls.server.cwd` setting
The settings file you shared looks like the one from the root of the repo (which unfortunately, is not going to work for VSCode < 1.89
). Did you create the settings file in examples/servers/.vscode/settings.json
before trying pygls: Debug Client
?
To simplify things I would also suggest setting pygls.server.debug
to false
for now.
is there any other requirement?
No it sounds like you have everything.
Is there any particular port requirements for server. I am wondering if my work antivirus or firewall will block something
Nothing in particular. At the moment the playground is not setup to communicate with a pygls
server over a port. Instead the servers in the playground will communicate with the client by printing to stdout.
However, when pygls.server.debug
is true
VSCode's debugger will attempt to use a local port which I guess your anti-virus might conflict with (sorry for any confusion caused there :sweat_smile: )
I am still getting errors. There is something else I am missing....Are you using linux or mac-os by any chance? Not sure why this is not working with VSCode 1.87.2 and VSCode 1.92.2 in Windows with python 3.9.6 .
I copied the settings.json to examples/servers/.vscode/settings.json as shown below:
I am getting error below in VScode 1.87.2 using Windows and Python 3.9.6:
2024-09-05 16:23:31.647 [info] Extension activated. 2024-09-05 16:23:55.530 [info] cwd: 'h:\SoftwareQA\sandbox\jobin\pygls\examples\servers/examples/servers' 2024-09-05 16:23:55.530 [info] server: 'code_actions.py' 2024-09-05 16:23:55.530 [info] Using user configured python environment: 'H:\SoftwareQA\Test\IR\PythonOfflineDownloads\3.9.6\venv\Scripts\python.exe' 2024-09-05 16:23:55.534 [info] client options: { "documentSelector": [ { "scheme": "file", "language": "plaintext" } ], "outputChannel": { "name": "pygls", "logLevel": 3 }, "connectionOptions": { "maxRestartCount": 0 } } 2024-09-05 16:23:55.538 [info] [Error - 4:23:55 PM] pygls client: couldn't create connection to server. 2024-09-05 16:23:55.539 [info] Launching server using command H:\SoftwareQA\Test\IR\PythonOfflineDownloads\3.9.6\venv\Scripts\python.exe failed. Error: spawn H:\SoftwareQA\Test\IR\PythonOfflineDownloads\3.9.6\venv\Scripts\python.exe ENOENT 2024-09-05 16:23:55.540 [error] There was a error starting the server: Launching server using command H:\SoftwareQA\Test\IR\PythonOfflineDownloads\3.9.6\venv\Scripts\python.exe failed. Error: spawn H:\SoftwareQA\Test\IR\PythonOfflineDownloads\3.9.6\venv\Scripts\python.exe ENOENT
I decided to try VScode 1.92.2 . I made sure to follow the instructions to install 'Recommended extension' and the extension window had 'Install Workspace extension'. I am getting below error:
2024-09-05 13:26:08.133 [info] [Error - 1:26:08 PM] pygls client: couldn't create connection to server. 2024-09-05 13:26:08.134 [info] Launching server using command H:\SoftwareQA\Test\IR\PythonOfflineDownloads\3.9.6\venv\Scripts\python.exe failed. Error: spawn H:\SoftwareQA\Test\IR\PythonOfflineDownloads\3.9.6\venv\Scripts\python.exe ENOENT 2024-09-05 13:26:08.134 [error] There was a error starting the server: Launching server using command H:\SoftwareQA\Test\IR\PythonOfflineDownloads\3.9.6\venv\Scripts\python.exe failed. Error: spawn H:\SoftwareQA\Test\IR\PythonOfflineDownloads\3.9.6\venv\Scripts\python.exe ENOENT
I tried on another computer that is not on my work domain. Same issue. In addition, I am getting these errors. Is there anything else that i could do to help troubleshoot this issue?
Here is my settings file that is present at D:\pygls.vscode and D:\pygls\examples\servers.vscode
{
"[plaintext]": {
// Uncomment to enable `textDocument/onTypeFormatting` requests
// "editor.formatOnType": true
},
// Uncomment to override Python interpreter used.
"pygls.server.pythonPath": "D:\\pygls\\env\\Scripts\\python.exe",
"pygls.server.debug": false,
"pygls.server.debugHost": "localhost",
"pygls.server.debugPort": 5678,
"pygls.server.launchScript": "code_actions.py", // This is relative to `pygls.server.cwd`
"pygls.server.cwd": "${workspaceFolder}/examples/servers",
"pygls.trace.server": "off",
"pygls.client.documentSelector": [
{
"scheme": "file",
"language": "plaintext"
}
],
// "pygls.jsonServer.exampleConfiguration": "some value here",
}
There was a error starting the server: Launching server using command H:\SoftwareQA\Test\IR\PythonOfflineDownloads\3.9.6\venv\Scripts\python.exe failed.
Error: spawn H:\SoftwareQA\Test\IR\PythonOfflineDownloads\3.9.6\venv\Scripts\python.exe ENOENT
I wish this error message was clearer.... if I remember rightly you see this when the python interpreter cannot find the *.py
file it's trying to run.
Looking at the settings.json file in your most recent screenshot, I think the pygls.server.cwd
setting is not quite right. Try setting it to just "${workspaceFolder}"
, or failing that to the absolute path to the examples/servers
folder of the repo.
I think you are close to getting it working! :crossed_fingers:
I guess the setting.json file at D:\pygls.vscode does not matter removed it. I am using VScode 1.92.2 with python 3.9.6 now.
The settings.json in D:\pygls\examples\servers\.vscode with below worked....
{
"[plaintext]": {
// Uncomment to enable `textDocument/onTypeFormatting` requests
// "editor.formatOnType": true
},
// Uncomment to override Python interpreter used.
"pygls.server.pythonPath": "H:\\SoftwareQA\\Test\\IR\\PythonOfflineDownloads\\3.9.6\\venv\\Scripts\\python.exe",
"pygls.server.debug": false,
// "pygls.server.debugHost": "localhost",
// "pygls.server.debugPort": 5678,
"pygls.server.launchScript": "code_actions.py", // This is relative to `pygls.server.cwd`
"pygls.server.cwd": "H:\\SoftwareQA\\sandbox\\jobin\\pygls\\examples\\servers",
"pygls.trace.server": "off",
"pygls.client.documentSelector": [
{
"scheme": "file",
"language": "plaintext"
}
],
// "pygls.jsonServer.exampleConfiguration": "some value here",
}
Thanks for your help.
Thanks again!!
Hi,
I am trying to use pygls-playground for a project.
I am using VSCode v1.87.2 in WINDOWS 11 x64
I am using https://pygls.readthedocs.io/en/latest/howto/use-the-pygls-playground.html as my guide.
i compile the node project using the commands - .vscode/extensions/pygls-playground/ $ npm install --no-save .vscode/extensions/pygls-playground/ $ npm run compile
This seems to have have created a folder out at .vscode\extensions\pygls-playground\out with following files.
I am stuck after this...the instructions there after say the following:
I dont see any directory with this name. Is this a typo or are they referring to .vscode/extensions/pygls-playground/
I opened .vscode/extensions/pygls-playground/ instead here...
Next it says to do the following:
I see this...I am not sure what to do here....
Can you help me out? Please give me some more guidance on this.