Skip to content
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

Automatic install even when grammarly-languageserver is in $PATH, lsp fails #56

Open
haselwarter opened this issue Aug 14, 2023 · 3 comments

Comments

@haselwarter
Copy link

I installed grammarly-languageserver via npm install -g @emacs-grammarly/grammarly-languageserver and installed emacs-grammarly from melpa using package.el. When I open a markdown file, say foo.md, I get an alert saying that no installed server supporting this file was found, and a suggestion to automatically install marksman or grammarly-ls. Running lsp in LaTeX mode works as expected.

If I accept the suggestion, grammarly-languageserver gets installed into ~/.emacs.d/.cache/lsp/npm/.

However, lsp still does not work for markdown files after this: activating lsp in foo.md now fails with the following:

node:internal/deps/undici/undici:11576
    Error.captureStackTrace(err, this);
          ^

TypeError: Failed to parse URL from /tmp/emacs-home/.emacs.d/.cache/lsp/npm/@emacs-grammarly/grammarly-languageserver/lib/node_modules/@emacs-grammarly/grammarly-languageserver/node_modules/web-tree-sitter/tree-sitter.wasm
    at Object.fetch (node:internal/deps/undici/undici:11576:11) {
  [cause]: TypeError [ERR_INVALID_URL]: Invalid URL
      at new NodeError (node:internal/errors:405:5)
      at new URL (node:internal/url:778:13)
      at new Request (node:internal/deps/undici/undici:7132:25)
      at fetch2 (node:internal/deps/undici/undici:10715:25)
      at Object.fetch (node:internal/deps/undici/undici:11574:18)
      at fetch (node:internal/process/pre_execution:270:25)
      at /tmp/emacs-home/.emacs.d/.cache/lsp/npm/@emacs-grammarly/grammarly-languageserver/lib/node_modules/@emacs-grammarly/grammarly-languageserver/node_modules/web-tree-sitter/tree-sitter.js:1:15192
      at /tmp/emacs-home/.emacs.d/.cache/lsp/npm/@emacs-grammarly/grammarly-languageserver/lib/node_modules/@emacs-grammarly/grammarly-languageserver/node_modules/web-tree-sitter/tree-sitter.js:1:15413
      at new Promise (<anonymous>)
      at Parser.init (/tmp/emacs-home/.emacs.d/.cache/lsp/npm/@emacs-grammarly/grammarly-languageserver/lib/node_modules/@emacs-grammarly/grammarly-languageserver/node_modules/web-tree-sitter/tree-sitter.js:1:332) {
    input: '/tmp/emacs-home/.emacs.d/.cache/lsp/npm/@emacs-grammarly/grammarly-languageserver/lib/node_modules/@emacs-grammarly/grammarly-languageserver/node_modules/web-tree-sitter/tree-sitter.wasm',
    code: 'ERR_INVALID_URL'
  }
}

Node.js v20.5.0

Process grammarly-ls stderr finished

I'm using Emacs from git, with the following minimal config

(progn
  (require 'package)
  (add-to-list 'package-archives
               '("melpa" . "https://melpa.org/packages/"))
  (package-initialize))

(use-package lsp-grammarly
  :ensure t
  :config (setq lsp-grammarly-suggestions-oxford-comma t
                lsp-grammarly-dialect "british"
                lsp-grammarly-audience "expert")
  )

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages '(lsp-grammarly)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
@jcs090218
Copy link
Member

grammarly-language-server is only supported with Node v16; therefore, you might need to downgrade your Node.js version and reinstall the package.

@haselwarter
Copy link
Author

I don't understand the difference in behaviour between markdown and LaTeX files. Why does lsp in markdown-mode insist on installing grammarly-ls on its own even though grammarly-languageserver is installed and works in LaTeX-mode?

I also don't understand why in LaTeX-mode, grammarly-languageserver works fine when using the version I installed manually via npm install -g @emacs-grammarly/grammarly-languageserver but the auto-installed version does not work?

@jcs090218
Copy link
Member

I don't understand the difference in behaviour between markdown and LaTeX files. Why does lsp in markdown-mode insist on installing grammarly-ls on its own even though grammarly-languageserver is installed and works in LaTeX-mode?

It shouldn't happen. They all share the same language-server. 🤔 This is the bug from lsp-mode if this is true.

I also don't understand why in LaTeX-mode, grammarly-languageserver works fine when using the version I installed manually via npm install -g @emacs-grammarly/grammarly-languageserver but the auto-installed version does not work?

This shouldn't happen too. The latest version for the grammarly-language-server is 0.2.1, and they should be the same. 🤔 Can you check the versions for both global and local language servers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants