emacs-lsp / lsp-python-ms

lsp-mode :heart: Microsoft's python language server
https://emacs-lsp.github.io/lsp-python-ms
BSD 3-Clause "New" or "Revised" License
190 stars 41 forks source link

Server fails to start: Server mspyls:21400 status:starting existed with status signal #45

Open micthiesen opened 5 years ago

micthiesen commented 5 years ago

Hello, I'm having some issues starting the LSP server. When I open a python file, immediately I receive the messages:

LSP :: Connected to [mspyls:29931 status:starting].
LSP :: mspyls has exited (abort trap: 6)
Server mspyls:29931 status:starting exited with status signal. Do you want to restart it? (y or n) y

If I choose yes, the same error is shown again.

I've spent some time trying to debug this (looking for logs and variable values) but I'm not sure how to debug further. Any help would be appreciated.

I'm on macOS Mojave 10.14.5 and using Emacs 26.2 with Spacemacs.

I've enabled logging via lsp-log-io. Here's one of the traces:

[Trace - 01:58:13 PM] Sending request 'initialize - (1)'.
Params: {
  "processId": 21245,
  "rootPath": "/Users/michael/Code/model-data-system/",
  "rootUri": "file:///Users/michael/Code/model-data-system/",
  "capabilities": {
    "workspace": {
      "workspaceEdit": {
        "documentChanges": true,
        "resourceOperations": [
          "create",
          "rename",
          "delete"
        ]
      },
      "applyEdit": true,
      "symbol": {
        "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
          ]
        }
      },
      "executeCommand": {
        "dynamicRegistration": false
      },
      "didChangeWatchedFiles": {
        "dynamicRegistration": true
      },
      "workspaceFolders": true,
      "configuration": true
    },
    "textDocument": {
      "declaration": {
        "linkSupport": true
      },
      "definition": {
        "linkSupport": true
      },
      "implementation": {
        "linkSupport": true
      },
      "typeDefinition": {
        "linkSupport": true
      },
      "synchronization": {
        "willSave": true,
        "didSave": true,
        "willSaveWaitUntil": true
      },
      "documentSymbol": {
        "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
          ]
        },
        "hierarchicalDocumentSymbolSupport": true
      },
      "formatting": {
        "dynamicRegistration": true
      },
      "codeAction": {
        "dynamicRegistration": true,
        "codeActionLiteralSupport": {
          "codeActionKind": {
            "valueSet": [
              "",
              "quickfix",
              "refactor",
              "refactor.extract",
              "refactor.inline",
              "refactor.rewrite",
              "source",
              "source.organizeImports"
            ]
          }
        }
      },
      "completion": {
        "completionItem": {
          "snippetSupport": true,
          "documentationFormat": [
            "markdown"
          ]
        },
        "contextSupport": true
      },
      "signatureHelp": {
        "signatureInformation": {
          "parameterInformation": {
            "labelOffsetSupport": true
          }
        }
      },
      "documentLink": {
        "dynamicRegistration": true
      },
      "hover": {
        "contentFormat": [
          "markdown",
          "plaintext"
        ]
      },
      "foldingRange": {
        "dynamicRegistration": true,
        "rangeLimit": null,
        "lineFoldingOnly": null
      }
    }
  },
  "initializationOptions": {
    "interpreter": {
      "properties": {
        "InterpreterPath": "/usr/bin/python",
        "Version": "2.7"
      }
    },
    "displayOptions": {
      "preferredFormat": "markdown",
      "trimDocumentationLines": false,
      "maxDocumentationLineLength": 0,
      "trimDocumentationText": false,
      "maxDocumentationTextLength": 0
    },
    "searchPaths": [],
    "analysisUpdates": true,
    "asyncStartup": true,
    "typeStubSearchPaths": [
      "/Users/michael/.emacs.d/mspyls/Typeshed"
    ]
  }
}
lisp-the-great commented 5 years ago

have you met the requirements at here, e.g. libicu

seagle0128 commented 5 years ago

It seems an issue of server configurations. Please check the information @lisp-the-great mentioned.

micthiesen commented 5 years ago

Thank you. I've done a brew install libicu and added the following to my .zshrc file:

export LC_ALL="en_US.UTF-8"
export LDFLAGS="-L/usr/local/opt/icu4c/lib"
export CPPFLAGS="-I/usr/local/opt/icu4c/include"

I also have openssl installed.

Interestingly, when I run the server from my terminal I get no output (i.e. no crash):

$ ./mspyls/Microsoft.Python.LanguageServer
(no output)
seagle0128 commented 5 years ago

There is no output in my env as well. I think it can be started from lsp-mode, right? Then this can be closed.

micthiesen commented 5 years ago

Unfortunately lsp-mode still says the server is crashing 🙁

seagle0128 commented 5 years ago

Can you share your configurations of lsp-python-ms and lsp-mode? Does the server crash actually? If so, you may need to inquiry to server maintainers.

micthiesen commented 5 years ago

You're right it may be the server. I wish I could be more useful debugging this (sorry). I'm using Spacemacs. I have the following layers enabled:

     (python :variables
            python-backend 'lsp)
     dap
     lsp

I've added lsp-python-ms to dotspacemacs-additional-packages and then have the following in dotspacemacs/user-config:

  (use-package lsp-python-ms
    :ensure t
    :demand
    :init (setq lsp-log-io t)
    :hook (python-mode . lsp))  ; or lsp-deferred
seagle0128 commented 5 years ago

Since I am not using spacemacs, I tried to reproduce with Vanilla Emacs on macOS and Ubuntu, but no issue there.

dangom commented 5 years ago

I could reproduce until a couple minutes ago, now it's fixed. Seemed to be the order with which lsp-python-ms and lsp were being loaded.

Here's my before and after:

Before

(use-package lsp-mode
  :defer 3
  :commands lsp
  :init (setq-default lsp-prefer-flymake nil
                      lsp-pyls-plugins-pylint-enabled nil
                      lsp-pyls-configuration-sources ["flake8"])
  :hook ((c++-mode sh-mode) . lsp))

(use-package lsp-python-ms
  :hook (python-mode . lsp)
  :config
  (setq lsp-python-ms-dir
        (expand-file-name "~/Projects/python-language-server/output/bin/Release/"))
  (setq lsp-python-ms-executable
        "~/.local/bin/Microsoft.Python.LanguageServer"))

After

(use-package lsp-mode
  :defer 3
  :commands lsp
  :init (setq-default lsp-prefer-flymake nil
                      lsp-restart 'auto-restart ;; Otherwise will get the restart message on exit.
                      lsp-pyls-plugins-pylint-enabled nil
                      lsp-pyls-configuration-sources ["flake8"])
  ;; THE lsp hook now goes here.
  :hook ((c++-mode sh-mode python-mode) . lsp))

(use-package lsp-python-ms
  ;; Need to demand otherwise this never gets loaded.
  :demand t
  ;; But only after lsp otherwise for some cryptic emacsy reason this doesn't work properly.
  :after lsp
  :config
  (setq lsp-python-ms-dir
        (expand-file-name "~/Projects/python-language-server/output/bin/Release/"))
  (setq lsp-python-ms-executable
        "~/.local/bin/Microsoft.Python.LanguageServer"))

What I notice, though, is that the server now starts but I get an LSP:: Task Cancelled for the first 20-30 seconds of usage. Seems like lsp-python-ms has to first generate some sort of cache, IDK. YMMV.

seagle0128 commented 5 years ago

@dangom Currently the configuration is simple as below.

(use-package lsp-python-ms
  :ensure t
  :demand
  :hook (python-mode . lsp))

What I notice, though, is that the server now starts but I get an LSP:: Task Cancelled for the first 20-30 seconds of usage. Seems like lsp-python-ms has to first generate some sort of cache, IDK. YMMV.

It's as designed for mspyls.