TerminalFi / LSP-copilot

GitHub Copilot support for Sublime Text LSP plugin provided through Copilot.vim.
658 stars 25 forks source link

Argument list too long; env multiplies with windows #163

Closed skjbulcher closed 3 months ago

skjbulcher commented 3 months ago

I have an issue that I am trying to troubleshoot:

Failed to start LSP-copilot - disabling for this window for the duration of the current session.
Re-enable by running "LSP: Enable Language Server In Project" from the Command Palette.

--- Error:---
[Errno 7] Argument list too long: '/home/[myuser]/.cache/sublime-text/Package Storage/lsp_utils/node-runtime/18.18.1/node/bin/node'

This issue most frequently occurs when I open a Sublime Text new window. However, it does occasionally occur in code windows as well. Today I had to find and click on the error quite a few times in order to access Sublime Text, which is a problem.

While I was searching around for ways to troubleshoot the issue, I discovered this when running LSP: Troubleshoot Server: 339439009-7f20b679-54c1-457f-9cc7-33e737355b1f

Note that I keep a lot of windows and tabs open in Sublime Text from time to time.

Running "LSP: Dump Window Configs" yielded this result for env:

env={'PATH': '/home/[myuser]/.cache/sublime-text/Package Storage/lsp_utils/node-runtime/18.18.1/node/bin:/home/[myuser]/.cache/sublime-text/Package Storage/lsp_utils/node-runtime/18.18.1/node/bin:/home/[myuser]/.cache/sublime-text/Package Storage/lsp_utils/node-runtime/18.18.1/node/bin:/home/[myuser]/.cache/sublime-text/Package Storage/lsp_utils/node-runtime/18.18.1/node/bin:/home/[myuser]/.cache/sublime-text/Package Storage/lsp_utils/node-runtime/18.18.1/node/bin:/home/[myuser]/.cache/sublime-text/Package Storage/lsp_utils/node-runtime/18.18.1/node/bin:'}

Depending on the window, the env is repeated more or less. I suspect that each window appends to the env, without any duplication.

I don't know if the "argument list too long" issue has anything to do with the environment, but even if it isn't the env could be handled better.

TerminalFi commented 3 months ago

Can you open Sublime Text in safe mode and then open the console and run

import os; print(os.environ["PATH"])
jfcherng commented 3 months ago

And could you just run LSP: Troubleshoot Server for LSP-copilot and paste the result here?

jfcherng commented 3 months ago

I have found the culprit is in lsp_utils. I will file a PR there soon.

Note that I keep a lot of windows

This triggers the bug.

skjbulcher commented 3 months ago

Can you open Sublime Text in safe mode and then open the console and run

import os; print(os.environ["PATH"])
>>> import os; print(os.environ["PATH"])
/home/[USERNAME]/google-cloud-sdk/bin:/home/[USERNAME]/.nvm/versions/node/v21.6.2/bin:/home/[USERNAME]/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/[USERNAME]/.local/bin
skjbulcher commented 3 months ago

And could you just run LSP: Troubleshoot Server for LSP-copilot and paste the result here?

Troubleshooting: LSP-copilot

Version

## Server Configuration
 - command
```json
[
  "${node_bin}",
  "${server_path}",
  "--stdio"
]

Active view

Project / Workspace

LSP configuration

{}

System PATH

jfcherng commented 3 months ago

The upstream has merged the fix so we just have to wait for its new release.