lsp-mode icon indicating copy to clipboard operation
lsp-mode copied to clipboard

lsp-lua-language-server-install-latest freezes emacs

Open jecars opened this issue 8 months ago • 8 comments

Thank you for the bug report

  • [x] I am using the latest version of lsp-mode related packages.
  • [x] I checked FAQ and Troubleshooting sections
  • [ ] You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

Emacs freezes after about 15-30 seconds after trying to install lua language server.

Steps to reproduce

M-x lsp-install-server RET lua-language-server RET

Expected behavior

Lua language server gets installed successfully

Which Language Server did you use?

lua-language-server

OS

MacOS

Error callstack

No error call stack. Emacs just hangs.

Anything else?

Version: GNU Emacs 30.1 (build 2, aarch64-apple-darwin24.3.0, NS appkit-2575.40 Version 15.3.1 (Build 24D70)) of 2025-03-01

What I've tried: I've removed calls to make-thread and funcall in the function lsp-download-install of lsp-mode.el. Once I do this, it still hangs emacs on the first install attempt. But once I kill emacs and try again, it works. I've replaced lsp-download-install with the following:

(cl-defun lsp-download-install (callback error-callback &key url asc-url pgp-key store-path decompress &allow-other-keys)
  (let* ((url (lsp-resolve-value url))
         (store-path (lsp-resolve-value store-path))
         ;; (decompress (lsp-resolve-value decompress))
         (download-path
          (pcase decompress
            (:gzip (concat store-path ".gz"))
            (:zip (concat store-path ".zip"))
            (:targz (concat store-path ".tar.gz"))
            (`nil store-path)
            (_ (error ":decompress must be `:gzip', `:zip', `:targz' or `nil'")))))
    (condition-case err
           (progn
             (when (f-exists? download-path)
               (f-delete download-path))
             (when (f-exists? store-path)
               (f-delete store-path))
             (lsp--info "Starting to download %s to %s..." url download-path)
             (mkdir (f-parent download-path) t)
             (url-copy-file url download-path)
             (lsp--info "Finished downloading %s..." download-path)
             (when (and lsp-verify-signature asc-url pgp-key)
               (if (executable-find epg-gpg-program)
                   (let ((asc-download-path (concat download-path ".asc"))
                         (context (epg-make-context))
                         (fingerprint)
                         (signature))
                     (when (f-exists? asc-download-path)
                       (f-delete asc-download-path))
                     (lsp--info "Starting to download %s to %s..." asc-url asc-download-path)
                     (url-copy-file asc-url asc-download-path)
                     (lsp--info "Finished downloading %s..." asc-download-path)
                     (epg-import-keys-from-string context pgp-key)
                     (setq fingerprint (epg-import-status-fingerprint
                                        (car
                                         (epg-import-result-imports
                                          (epg-context-result-for context 'import)))))
                     (lsp--info "Verifying signature %s..." asc-download-path)
                     (epg-verify-file context asc-download-path download-path)
                     (setq signature (car (epg-context-result-for context 'verify)))
                     (unless (and
                              (eq (epg-signature-status signature) 'good)
                              (equal (epg-signature-fingerprint signature) fingerprint))
                       (error "Failed to verify GPG signature: %s" (epg-signature-to-string signature))))
                 (lsp--warn "GPG is not installed, skipping the signature check.")))
             (when decompress
               (lsp--info "Decompressing %s..." download-path)
               (pcase decompress
                 (:gzip
                  (lsp-gunzip download-path))
                 (:zip (lsp-unzip download-path (f-parent store-path)))
                 (:targz (lsp-tar-gz-decompress download-path (f-parent store-path))))
               (lsp--info "Decompressed %s..." store-path))
             (message "Succes"))
         (error (message "Failure")))))

I couldn't figure out how to fix it beyond this.

jecars avatar Mar 30 '25 02:03 jecars

This also happens for eslint There is some bug in Emacs 30.1 on Mac.

tetrasmolyn avatar Apr 03 '25 16:04 tetrasmolyn

Looks like it's a known bug? https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75275

tetrasmolyn avatar Apr 03 '25 17:04 tetrasmolyn

I'm experiencing the same issue while attempting to download eslint. The *Messages* buffer displays the following:

Image

Emacs becomes unresponsive during the Contacting host: github.com:443 operation.

datalek avatar Apr 04 '25 21:04 datalek

This also happens for eslint There is some bug in Emacs 30.1 on Mac.

I just ran into this for the eslint LSP. Here is what I did to install it manually:

  1. Get the .vsix download link from lsp-eslint-download-url in lsp-mode in ~/.emacs.d/elpa (was https://github.com/emacs-lsp/lsp-server-binaries/blob/master/dbaeumer.vscode-eslint-3.0.10.vsix?raw=true for me)
  2. Download the .vsix file
  3. Call unzip on the .vsix file
  4. Place the extension folder under ~/.emacs.d/.cache/lsp/eslint/unzipped

The ESLint server should now automatically start with your Typescript server. Hope this helps somebody.

marlonschlosshauer avatar May 08 '25 20:05 marlonschlosshauer

For lua-language-server it can be fixed by building it manually and moving to emacs lsp directory like so:

  1. git clone https://github.com/LuaLS/lua-language-server
  2. cd lua-language-server && ./make install
  3. cd .. && mv lua-language-server ~/.config/emacs/.local/etc/lsp/

ykav-flant avatar May 23 '25 11:05 ykav-flant

This appears to only be a problem when using the Emacs GUI and is not an lsp-mode specific bug. Downloading eslint consistently caused GUI Emacs to crash while the same command call succeeded in terminal Emacs.

Using a lot of print statements, I managed to track the problem down to accept-process-output whose callstack is url-retrieve-synchronously <-- url-copy-file <-- lsp-download-install <-- lsp-lua-language-server-install-latest <-- lsp--install-server-internal <-- lsp-install-server.

Minimal code to cause Emacs to hang

Here's a more minimal call that causes Emacs to hang:

(make-thread
     (lambda ()
       (url-retrieve-synchronously
        "https://github.com/LuaLS/lua-language-server/releases/download/3.14.0/lua-language-server-3.14.0-darwin-arm64.tar.gz")))

It seems like any instance of calling url-retrieve-synchronously inside the make-thread function parameter might cause this problem.

Operating system and Emacs version

I'm also on MacOS, currently using GNU Emacs 30.0.93 (build 2, aarch64-apple-darwin24.1.0, NS appkit-2575.20 Version 15.1.1 (Build 24B91)) of 2024-12-26.

drgillis avatar Jun 09 '25 22:06 drgillis

A workaround I did for eca which should help lsp-mode as well:

(let ((curl-cmd (or (executable-find "curl")
                      (executable-find "curl.exe"))))
    (unless curl-cmd
      (error "Curl not found. Please install curl or customize eca-custom-command"))
    (let ((exit-code (shell-command (format "%s -L -s -S -f -o %s %s"
                                            (shell-quote-argument curl-cmd)
                                            (shell-quote-argument path)
                                            (shell-quote-argument url)))))
      (unless (= exit-code 0)
        (error "Curl failed with exit code %d" exit-code))))

This inside a make-thread works nice

ericdallo avatar Jul 28 '25 23:07 ericdallo

This seems to be happening in Emacs@31 too.

In emacs@29 I tried to install on GUI, it didnt freeze but the process never ended. I tried on 29 on shell and it worked almost instantly

viglioni avatar Oct 02 '25 11:10 viglioni