Skip to content

error starting LSP client: nil #428

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

Open
georgeharker opened this issue Apr 3, 2025 · 21 comments
Open

error starting LSP client: nil #428

georgeharker opened this issue Apr 3, 2025 · 21 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@georgeharker
Copy link

Between the beta branch and master there appears to be some sort of issue.

I'm on Neovim 0.11 and I get error on startup "error starting LSP client: nil". On beta I do not.

What's odd is that the lsp client appears to have started and LSPInfo shows it. I've tried binary and nodejs for the server type - same either way.

This doesn't seem to happen on 0.10.5 - same configs, but in fairness that's a debian install and i'm on osx usually.

I don' think this has to do with downloading the binary - it seems to do that fine and I can run the downloaded js or binary fine.

I've enabled logging and when it fails it looks like this:

2025-04-03 09:09:00.061 [1] [DEBUG]: active plugin config:
{
  config = {
    copilot_node_command = "node",
    filetypes = {
      ["."] = false,
      cvs = false,
      gitcommit = false,
      gitrebase = false,
      help = false,
      hgcommit = false,
      markdown = false,
      svn = false,
      yaml = false
    },
    logger = {
      file = "/Users/geohar/.local/state/nvim/copilot-lua.log",
      file_log_level = 0,
      log_lsp_messages = false,
      print_log_level = 3,
      trace_lsp = "verbose",
      trace_lsp_progress = false
    },
    panel = {
      auto_refresh = false,
      enabled = false,
      keymap = {
        accept = "<CR>",
        jump_next = "]]",
        jump_prev = "[[",
        open = "<M-CR>",
        refresh = "gr"
      },
      layout = {
        position = "bottom",
        ratio = 0.4
      }
    },
    root_dir = <function 1>,
    server = {
      type = "binary"
    },
    server_opts_overrides = {},
    should_attach = <function 2>,
    suggestion = {
      auto_trigger = false,
      debounce = 75,
      enabled = true,
      hide_during_completion = true,
      keymap = {
        accept = "<M-l>",
        accept_line = false,
        accept_word = false,
        dismiss = "<C-]>",
        next = "<M-]>",
        prev = "<M-[>"
      }
    },
    workspace_folders = {}
  },
  get_root_dir = <function 3>,
  setup = <function 4>
}
2025-04-03 09:09:00.062 [2] [DEBUG]: active LSP config (may change runtime):
{
  capabilities = {
    general = {
      positionEncodings = { "utf-8", "utf-16", "utf-32" }
    },
    textDocument = {
      callHierarchy = {
        dynamicRegistration = false
      },
      codeAction = {
        codeActionLiteralSupport = {
          codeActionKind = {
            valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" }
          }
        },
        dataSupport = true,
        dynamicRegistration = true,
        isPreferredSupport = true,
        resolveSupport = {
          properties = { "edit", "command" }
        }
      },
      codeLens = {
        dynamicRegistration = false,
        resolveSupport = {
          properties = { "command" }
        }
      },
      completion = {
        completionItem = {
          commitCharactersSupport = false,
          deprecatedSupport = true,
          documentationFormat = { "markdown", "plaintext" },
          preselectSupport = false,
          resolveSupport = {
            properties = { "additionalTextEdits", "command" }
          },
          snippetSupport = true,
          tagSupport = {
            valueSet = { 1 }
          }
        },
        completionItemKind = {
          valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }
        },
        completionList = {
          itemDefaults = { "editRange", "insertTextFormat", "insertTextMode", "data" }
        },
        contextSupport = true,
        dynamicRegistration = false
      },
      declaration = {
        linkSupport = true
      },
      definition = {
        dynamicRegistration = true,
        linkSupport = true
      },
      diagnostic = {
        dynamicRegistration = false
      },
      documentHighlight = {
        dynamicRegistration = false
      },
      documentSymbol = {
        dynamicRegistration = false,
        hierarchicalDocumentSymbolSupport = true,
        symbolKind = {
          valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }
        }
      },
      foldingRange = {
        dynamicRegistration = false,
        foldingRange = {
          collapsedText = true
        },
        lineFoldingOnly = true
      },
      formatting = {
        dynamicRegistration = true
      },
      hover = {
        contentFormat = { "markdown", "plaintext" },
        dynamicRegistration = true
      },
      implementation = {
        linkSupport = true
      },
      inlayHint = {
        dynamicRegistration = true,
        resolveSupport = {
          properties = { "textEdits", "tooltip", "location", "command" }
        }
      },
      publishDiagnostics = {
        dataSupport = true,
        relatedInformation = true,
        tagSupport = {
          valueSet = { 1, 2 }
        }
      },
      rangeFormatting = {
        dynamicRegistration = true,
        rangesSupport = true
      },
      references = {
        dynamicRegistration = false
      },
      rename = {
        dynamicRegistration = true,
        prepareSupport = true
      },
      semanticTokens = {
        augmentsSyntaxTokens = true,
        dynamicRegistration = false,
        formats = { "relative" },
        multilineTokenSupport = false,
        overlappingTokenSupport = true,
        requests = {
          full = {
            delta = true
          },
          range = false
        },
        serverCancelSupport = false,
        tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" },
        tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" }
      },
      signatureHelp = {
        dynamicRegistration = false,
        signatureInformation = {
          activeParameterSupport = true,
          documentationFormat = { "markdown", "plaintext" },
          parameterInformation = {
            labelOffsetSupport = true
          }
        }
      },
      synchronization = {
        didSave = true,
        dynamicRegistration = false,
        willSave = true,
        willSaveWaitUntil = true
      },
      typeDefinition = {
        linkSupport = true
      }
    },
    window = {
      showDocument = {
        support = true
      },
      showMessage = {
        messageActionItem = {
          additionalPropertiesSupport = true
        }
      },
      workDoneProgress = true
    },
    workspace = {
      workspaceFolders = true
    }
  },
  cmd = { "/Users/geohar/.local/share/nvim/lazy/copilot.lua/copilot/darwin-arm64/copilot-language-server-1.296.0", "--stdio" },
  get_language_id = <function 1>,
  handlers = {
    ["$/logTrace"] = <function 2>,
    PanelSolution = <function 3>,
    PanelSolutionsDone = <function 4>,
    statusNotification = <function 5>,
    ["window/showDocument"] = <function 6>
  },
  init_options = {
    editorInfo = {
      name = "Neovim",
      version = "0.11.0"
    },
    editorPluginInfo = {
      name = "copilot.lua",
      version = "1.296.0"
    }
  },
  name = "copilot",
  on_exit = <function 7>,
  on_init = <function 8>,
  root_dir = "/Users/geohar",
  settings = {
    telemetry = {
      telemetryLevel = "all"
    }
  },
  workspace_folders = { {
      name = "/Users/geohar",
      uri = "file:///Users/geohar"
    } }
}
2025-04-03 09:09:00.064 [3] [ERROR]: error starting LSP client: nil

@georgeharker
Copy link
Author

This actually appears to be related to auth method.

An auth token generated by gh auth token and set in GH_COPILOT_TOKEN or GITHUB_COPILOT_TOKEN does not work, whereas using the GitHub.com/device/login method does. I've tried regenerating a new token, but that still fails.

@AntoineGS
Copy link
Collaborator

Thank you for figuring out the root cause!
I will work on a fix :)

@AntoineGS AntoineGS self-assigned this Apr 5, 2025
@AntoineGS
Copy link
Collaborator

In the current version, it seems that using :Copilot auth when you have the token env variable set works.
However it does not autologin so I am investigating that part, would you mind doing a test to see if you get the same result with :Copilot auth?

@georgeharker
Copy link
Author

I can confirm that if the env bars are not set and I use copilot with things work fine.

@georgeharker
Copy link
Author

I'll investigate if this works now with copilot auth and the env bars set (it didn't before)

@georgeharker
Copy link
Author

If I have GH_COPILOT_TOKEN set I still get the lsp null error at startup and doing Copilot auth claims it's authenticated with the the environment variable, but doesn't work.

@AntoineGS
Copy link
Collaborator

So I still cannot replicate the nil error, however throughout my tests (and asking tpope maintainer of copilot.vim) that the token generated by the gh cli tool is not compatible with Copilot.
I have updated the documentation to reflect this, and added a new command to get the token out of the configuration file created when running :Copilot auth.
I am unsure if it fixes your issue or not though.

@cxwx
Copy link

cxwx commented Apr 10, 2025

nvim 0.11 same issue
[Copilot.lua] LSP client failed to start (no client ID returned)

@AntoineGS
Copy link
Collaborator

Are you also on OSX?
Can you try both with the config server.type = binary and server.type = nodejs?

@cxwx
Copy link

cxwx commented Apr 10, 2025

yes osx, type= nodejs default cause this problem
type = binary will downloading the binary, But I've install the copilot-language-server using Mason and set it to env PATH, not sure why

@cxwx
Copy link

cxwx commented Apr 10, 2025

if set type = binary
It cause the same [Copilot.lua] LSP client failed to start (no client ID returned) when reopen the neovim
I got the binary file

~/software/nvim/lazy/plugins/copilot.lua/copilot/darwin-arm64

I've change the plugins directory from ~/.local/share/nvim/plugins to ~/software/nvim/lazy/plugins/

Does this cause the problem?

@AntoineGS
Copy link
Collaborator

Hmm, not sure.
Try downloading it from the official LSP repo and setting the path manually.
I described how to do it here on another Issue.

@cxwx
Copy link

cxwx commented Apr 12, 2025

Hmm, not sure. Try downloading it from the official LSP repo and setting the path manually. I described how to do it here on another Issue.

Download from https://github.com/github/copilot-language-server-release/releases/tag/1.298.0
still not works,

@AntoineGS
Copy link
Collaborator

What happens if you run it directly from the command line?
Like: ./copilot-language-server-1.298.0 --stdio for the binary and node language-server.js --stdio?
Do you got an error or does it just 'wait' with no message and you need to press CTRL-C to cancel the execution?

@georgeharker
Copy link
Author

If I run the language server it just waits and I have to ctrl-C, that happens with or without the env var set.

Same on node and binary.

I can successfully use the permanent login method, following the steps for the env based approach however, results in the same thing - no idea why, but for now, I'll just use the permanent method.

@AntoineGS
Copy link
Collaborator

This one bugs me as I have no idea why it behaves this way in your environment :(
If ever I stumble on something I will report back here, though without a way to reproduce it I do not see how I can investigate further.
I even set up automated tests with OSX hoping it would break but it passed all my tests.

@AntoineGS AntoineGS added the help wanted Extra attention is needed label Apr 14, 2025
@georgeharker
Copy link
Author

I wonder if it's because I have GH_TOKEN set also (for other purposes)

@cxwx
Copy link

cxwx commented Apr 15, 2025

If I run the language server it just waits and I have to ctrl-C, that happens with or without the env var set.

Same on node and binary.

I can successfully use the permanent login method, following the steps for the env based approach however, results in the same thing - no idea why, but for now, I'll just use the permanent method.

same

@cxwx
Copy link

cxwx commented Apr 28, 2025

seems worked now, I'm not sure what changes

@garrett-hopper
Copy link

garrett-hopper commented May 20, 2025

FWIW, I was getting this as a race condition on about half of Nvim starts. Adding event = "VeryLazy" to my Lazy.nvim config fixed the race condition. Not quite sure what it was racing with exactly though. 🤷

Specifically this error: [Copilot.lua] LSP client failed to start (no client ID returned)

@raphaelhovsepyan
Copy link

I had lazy = false in avante config, setting it to true fixed the issue for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants