bash-language-server icon indicating copy to clipboard operation
bash-language-server copied to clipboard

Bashls not working on Ubuntu 22.04

Open tyrdal opened this issue 2 years ago • 9 comments

I want to to use bash-language-server on Ubuntu 22.04. For this I did:

  • sudo apt install npm
  • sudo npm i -g bash-language-server

The latter gave me these warnings: npm WARN EBADENGINE Unsupported engine { npm WARN EBADENGINE package: '[email protected]', npm WARN EBADENGINE required: { node: '>=14.0.0' }, npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' } npm WARN EBADENGINE } npm WARN deprecated [email protected]: this library is no longer supported npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142 npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142

When trying to start it I get: ❯ bash-language-server /usr/local/lib/node_modules/bash-language-server/node_modules/vscode-jsonrpc/lib/common/linkedMap.js:40 return this._head?.value; ^

SyntaxError: Unexpected token '.' at wrapSafe (internal/modules/cjs/loader.js:915:16) at Module._compile (internal/modules/cjs/loader.js:963:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object. (/usr/local/lib/node_modules/bash-language-server/node_modules/vscode-jsonrpc/lib/common/api.js:37:21) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) zsh: exit 1 bash-language-server

Am I doing something wrong or is something broken?

tyrdal avatar Aug 03 '22 07:08 tyrdal

I guess you need bash-language-server start

morph027 avatar Aug 03 '22 17:08 morph027

Same result. And the call on the command line s just for verification. Usually my editor starts the language servers. And the editor reports that it exited with return code 1.

tyrdal avatar Aug 04 '22 05:08 tyrdal

Hm. I do have 22.04 too but installed node via nodeenv

morph027 avatar Aug 04 '22 06:08 morph027

I do have the same issue also on ubuntu 22.04, get the same raised error

node --version gives me v12.22.79, maybe this is the reason?

milanglacier avatar Aug 06 '22 19:08 milanglacier

can confirm this is because node 12 isn't compatible with bash-ls. Try to install node 18 by nvm rather than nodejs in apt, and bash-ls can work

milanglacier avatar Aug 10 '22 19:08 milanglacier

Same problem here. The question though is if node 18 is really required. How is it possible that a node version that is around 2 years old is already incompatible?

Installing node with nvm has important security and maintenance implications compared to using packages provided by ubuntu and covered by their security team.

I guess what I am trying to say is that if this software works with a previous node version, the requirement should be changed so it is more accessible. This is just what is keeping me from using this, sadly.

diego-treitos avatar Aug 11 '22 20:08 diego-treitos

Some of the transient dependencies requires node 14 as we can see from the log here.

npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=14.0.0' },

Same problem here. The question though is if node 18 is really required. How is it possible that a node version that is around 2 years old is already incompatible?

Node 14 should be fine. Node 12 is 3 years old (23 Apr 2019) and security support stopped 3 months ago (30 Apr 2022). So I wouldn't recommend that people still use that version of node.

With sudo apt -y install nodejs which version do you get? Isn't the latest version on ubuntu > 12?

skovhus avatar Aug 11 '22 20:08 skovhus

The version that comes with Ubuntu 22.04 is 12.22.9 which seems it was released on January this year, however it is true that Node 12 is already out of its LTS span and Ubuntu should probably have shipped a more recent version.

On the other hand, they will patch this version in case there is any CVE and the fixes will be applied whenever I update the system packages so, in that regard, I believe it is more secure.

The next ubuntu version will be released in a couple of months and will ship Node 16 so hopefully it will work by that time, unless the requirements are bumped up :)

diego-treitos avatar Aug 12 '22 07:08 diego-treitos

Ok, after installing nodejs v18 via a NodeSourcePPA everything works as expected.

tyrdal avatar Aug 16 '22 10:08 tyrdal