bash-language-server: "Can't find bash-language-server on your PATH...." on Windows

I’ve installed the package as advised but the extension fails with this error:

image

PS C:\Users\fakui> npm i -g bash-language-server
C:\Users\fakui\AppData\Roaming\npm\bash-language-server -> C:\Users\fakui\AppData\Roaming\npm\node_modules\bash-language-server\bin\main.js
+ bash-language-server@1.3.0
updated 1 package in 1.253s
PS C:\Users\fakui> node -v
v10.0.0
PS C:\Users\fakui> (Get-ChildItem Env:Path).Value
C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Python36\Scripts\;C:\Program Files\Python36\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Common Files\Autodesk Shared\;D:\Program_Files\Strawberry\c\bin;D:\Program_Files\Strawberry\perl\site\bin;D:\Program_Files\Strawberry\perl\bin;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\Users\fakui\AppData\Local\Microsoft\WindowsApps;;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\fakui\AppData\Roaming\npm

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 42

Most upvoted comments

I have the same problem. Although I had installed bash-language-server and set BashIDE-path

I was having this problem as well, and oddly, by running the following command it fixed it for me on Ubuntu 18.04, VS Code 1.27.2:

sudo npm i -g bash-language-server tree-sitter tree-sitter-bash --unsafe-perm

I ran the install command for each of the modules separately, and that didn’t work… it was only when I did it all at once did it resolve things.

Setting an absolute path for Bash Ide: Path worked for me.

I am running window 10 home. I am having the same issues. I tried installing and re-installing VS code reports image

I also tried

Possible alternatives to Node spawn on windows:

https://github.com/MarcDiethelm/superspawn
https://www.npmjs.com/package/cross-spawn

Nothing seems to work still getting same error

PS C:\WINDOWS\system32> bash-language-server -v Version is 1.3.1 Any Fix for this?

I’ve just released version 1.3.1 of the VSCode extension which adds a new configuration option bashIde.path. Please see if you can use that to run it on Windows. As for Atom I think it’s a good idea to use cross-spawn.

This thread could be conflating 2 issues here. I think that you can build bash-language-server successfully on Windows if you have the correct prerequisites. Building it with the npm build tools, puts the application somewhere in your user profile and in your PATH (in my case it’s %USERPROFILE%\AppData\Roaming\npm\bash-language-server, YMMV.

However the ability of VSCode or Atom to launch it is a separate issue. Despite the bash-language-server existing in the Windows %PATH% and responding correctly in Powershell, it seems that the Node applications have trouble spawning it as a process and issue misleading error messages like ENOENT and claim that they can’t find bash-language-server. IMHO it looks like a bug in the Node spawn command in Windows. Some elaboration here: mads-hartmann/ide-bash#4

Building on Windows

First you need to install python and windows build tools via npm in Powershell (Administrator mode)… per https://www.npmjs.com/package/windows-build-tools installed to %USERPROFILE%.windows-build-tools\python27 be patient, it may take 15 minutes or more, even on a high spec PC

npm install --global --production windows-build-tools

Then install bash-language-server

npm i -g bash-language-server

image

Launching from VSCode or Atom

For Atom, I think it’s happening here in main.js. Maybe “spawn” isn’t smart enough to find the npm package in windows

https://github.com/mads-hartmann/ide-bash/blob/ff7acfe95a37915ed8e1effe75df88e2b073c5e0/src/main.js#L29-L31

Similar “spawn” issues on SO:

Possible alternatives to Node spawn on windows: