language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Cannot read properties of undefined (reading 'debug') [emacs-lsp]

Open gustavotcabral opened this issue 2 years ago • 2 comments

Describe the bug

The language server is failing on initialization when used with the emacs-lsp client: "Cannot read properties of undefined (reading 'debug')"

I fixed it using optional chaining (?.) when accessing the .debug attribute (file server.ts):

... .['language-server']?.debug

Reproduction

Simple initialization.

Expected behaviour

The language server successfully initializes.

System Info

  • OS: Ubuntu Bionic 18.04
  • IDE: GNU Emacs 28.1 + Emacs LSP

Which package is the issue about?

svelte-language-server

Additional Information, eg. Screenshots

No response

gustavotcabral avatar Sep 18 '22 01:09 gustavotcabral

Hi, @jasonlyu123

I think you need to fix one more occurrence of .debug.

gustavotcabral avatar Sep 18 '22 04:09 gustavotcabral

Since the fix for this doesn't seem to have landed in a release yet I made a PKGBUILD for Arch users that installs the latest version from git:

_pkgname=svelte-language-server
pkgname="nodejs-${_pkgname}-git"
pkgver=extensions.106.1.0.r8.g5ebd8992
pkgrel=1
pkgdesc='A language server (implementing the language server protocol) for Svelte.'
arch=('any')
url='https://github.com/sveltejs/language-tools'
license=('MIT')
conflicts=('nodejs-svelte-language-server')
depends=('nodejs>=12')
makedepends=('npm>=8' 'jq' 'git')
source=("${pkgname}::git+${url}.git#branch=master")
sha256sums=('SKIP')

pkgver() {
  cd "$pkgname"
  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd "$pkgname"
  npm install --cache="${srcdir}/npm-cache"
  npm run build --workspace="${_pkgname}"
}

package() {
  cd "$pkgname"
  # NOTE: taken from here:
  # https://github.com/yochananmarqos/pkgbuilds/blob/master/pnpm/PKGBUILD#L27
  local tmppackage="$(mktemp)"
  local npmdir="packages/${_pkgname#svelte-}"
  local pkgjson="$npmdir/package.json"
  jq ".version = \"$pkgver\"" "$pkgjson" > "$tmppackage"
  mv "$tmppackage" "$pkgjson"
  chmod 644 "$pkgjson"
  npm pack --workspace="${_pkgname}"
  npm install -g --prefix="$pkgdir"/usr "${_pkgname}-$pkgver.tgz"
  chown -R root:root "${pkgdir}"
}

ohmree avatar Sep 23 '22 08:09 ohmree

This is failing since version 0.14.34.

michaelfranzl avatar Sep 26 '22 12:09 michaelfranzl