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

Windows support #5

Closed
asampal opened this issue Mar 1, 2018 · 31 comments
Closed

Windows support #5

asampal opened this issue Mar 1, 2018 · 31 comments
Labels
bug Something isn't working

Comments

@asampal
Copy link

asampal commented Mar 1, 2018

Seeing this when I switch to a bash file, in Visual Studio Code 1.20.1, Windows 10, extension v. 1.1.4:

module.js:672
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: \\?\C:\Users\asampaleanu\.vscode\extensions\mads-hartmann.bash-ide-vscode-1.1.4\server\node_modules\tree-sitter\build\Release\tree_sitter_runtime_binding.node is not a valid Win32 application\\?\C:\Users\asampaleanu\.vscode\extensions\mads-hartmann.bash-ide-vscode-1.1.4\server\node_modules\tree-sitter\build\Release\tree_sitter_runtime_binding.node
    at Object.Module._extensions..node (module.js:672:18)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\asampaleanu\.vscode\extensions\mads-hartmann.bash-ide-vscode-1.1.4\server\node_modules\tree-sitter\index.js:1:125)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
[Info  - 9:28:54 AM] Connection to server got closed. Server will restart.
module.js:672
  return process.dlopen(module, path._makeLong(filename));
@asampal asampal changed the title Error in VSCode: tree_sitter_runtime_binding.node is not a valid Win32 application VSCode client: tree_sitter_runtime_binding.node is not a valid Win32 application Mar 1, 2018
@mads-hartmann mads-hartmann self-assigned this Mar 1, 2018
@mads-hartmann
Copy link
Collaborator

@asampal Thanks, I believe I know how to fix this. I've accidentally shipped an OS X binary I believe ;)

@asampal
Copy link
Author

asampal commented Mar 1, 2018

Great - looking forward to the fix.

@mads-hartmann
Copy link
Collaborator

@asampal Could you try installing version 1.1.6? I believe I've fixed the issue ☺️

@mads-hartmann
Copy link
Collaborator

@asampal Please reopen if you're still having issues 🙂

@asampal
Copy link
Author

asampal commented Mar 3, 2018

I'm still seeing the same problem @mads-hartmann . Should the Windows binary be built automatically when the extension is installed? The error message is exactly the same, so it looks like the extension is still somehow not building for Windows.

@asampal
Copy link
Author

asampal commented Mar 3, 2018

Could it be that my system is somehow being detected as running OS X?

@mads-hartmann
Copy link
Collaborator

@asampal Turns out it's a bit more complicated to ship an extension that has native dependencies than I thought 🙂I found this guide that I'll try to follow.

@mads-hartmann mads-hartmann reopened this Mar 3, 2018
@mads-hartmann
Copy link
Collaborator

@asampal I'm trying a different approach. Can you run npm i -g bash-language-server for me to see if the server installs on your system. And if it does, can you then try running bash-language-server -h to see if it executes properly?

@asampal
Copy link
Author

asampal commented Mar 3, 2018

I get this when I try to install the language server:

adi@VESUVIUS C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter                                                                                                                                
$ if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\n
pm\node_modules\node-gyp\bin\node-gyp.js" rebuild )                                                                                                                                                                                     
Warning: Missing input files:                                                                                                                                                                                                           
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\prepare_grammar\expand_tokens.cc                                          
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\syntax_grammar.cc                                                         
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\prepare_grammar\token_description.cc                                      
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\build_tables\lookahead_set.cc                                             
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\build_tables\lex_item_transitions.cc                                      
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\prepare_grammar\expand_repeats.cc                                         
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\parse_table.cc                                                            
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\externals\json-parser\json.c                                                           
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\prepare_grammar\extract_choices.cc                                        
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\prepare_grammar\normalize_rules.cc                                        
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\rules\character_set.cc                                                    
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\generate_code\c_code.cc                                                   
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\prepare_grammar\extract_tokens.cc                                         
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\prepare_grammar\flatten_grammar.cc                                        
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\prepare_grammar\intern_symbols.cc                                         
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\rules\choice.cc                                                           
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\prepare_grammar\prepare_grammar.cc                                        
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\build_tables\lex_table_builder.cc                                         
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\rules\metadata.cc                                                         
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\rule.cc                                                                   
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\lex_table.cc                                                              
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\build_tables\lex_item.cc                                                  
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\build_tables\parse_table_builder.cc                                       
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\build_tables\parse_item.cc                                                
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\compile.cc                                                                
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\build_tables\parse_item_set_builder.cc                                    
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\rules\repeat.cc                                                           
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\rules\seq.cc                                                              
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\prepare_grammar\parse_regex.cc                                            
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\build_tables\rule_can_be_blank.cc                                         
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\util\string_helpers.cc                                                    
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\precedence_range.cc                                                       
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\build_tables\lex_conflict_manager.cc                                      
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\..\..\..\vendor\tree-sitter\src\compiler\parse_grammar.cc                                                          
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.                                                                                                                             
C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter\build\vendor\tree-sitter\runtime.vcxproj(28,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm 
 that the path in the <Import> declaration is correct, and that the file exists on disk.                                                                                                                                                
gyp ERR! build error                                                                                                                                                                                                                    
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1                                                                                                                              
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)                                                                                                          
gyp ERR! stack     at ChildProcess.emit (events.js:127:13)                                                                                                                                                                              
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)                                                                                                                                            
gyp ERR! System Windows_NT 10.0.16299                                                                                                                                                                                                   
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"                                                                               
gyp ERR! cwd C:\Users\adi\AppData\Roaming\npm\node_modules\bash-language-server\node_modules\tree-sitter                                                                                                                                
gyp ERR! node -v v9.6.1                                                                                                                                                                                                                 
gyp ERR! node-gyp -v v3.6.2                                                                                                                                                                                                             
gyp ERR! not ok                                                                                                                                                                                                                         
npm ERR! code ELIFECYCLE                                                                                                                                                                                                                
npm ERR! errno 1                                                                                                                                                                                                                        
npm ERR! tree-sitter@0.9.2 install: `node-gyp rebuild`                                                                                                                                                                                  
npm ERR! Exit status 1                                                                                                                                                                                                                  
npm ERR!                                                                                                                                                                                                                                
npm ERR! Failed at the tree-sitter@0.9.2 install script.                                                                                                                                                                                
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.                                                                                                                                      
                                                                                                                                                                                                                                        
npm ERR! A complete log of this run can be found in:                                                                                                                                                                                    
npm ERR!     C:\Users\adi\AppData\Roaming\npm-cache\_logs\2018-03-03T21_03_30_599Z-debug.log                                                                                                                                            

@asampal
Copy link
Author

asampal commented Mar 3, 2018

The full log is for the above is:

2018-03-03T21_03_30_599Z-debug.log

I had already installed node-gyp as per, instructions, along with it's dependency of the Microsoft Build Tools (for VS 20017).

@asampal
Copy link
Author

asampal commented Mar 3, 2018

Maybe you could, at least as an option, use the WSL (Windows Subsystem for Linux) for what you need to do. Since the Fall Creators Update it's quite interoperable with Windows. Some of the files here might be of help.

@mads-hartmann
Copy link
Collaborator

@asampal I'd love your help on this. I don't have access to a windows computer right now so it's hard for me to work on it and my knowledge of windows is very limited.

@mads-hartmann mads-hartmann added help wanted bug Something isn't working labels Mar 4, 2018
@mads-hartmann mads-hartmann changed the title VSCode client: tree_sitter_runtime_binding.node is not a valid Win32 application Windows support Mar 4, 2018
@mads-hartmann mads-hartmann removed their assignment Mar 4, 2018
@mads-hartmann
Copy link
Collaborator

The goal is to get npm i -g bash-language-server to work on Windows. If that works the rest of the client then we should have windows support as the client is platform independent.

@seflue
Copy link

seflue commented Mar 15, 2018

After playing around with various settings of msvs_version I got bash-language-server installed via npm on Windows 10. But now I get the following error message in VSC:

Can't find bash-langauge-server [sic!] on your PATH. Please install it using npm i -g bash-language-server.

But looking in my environment variables I found the relevant folder (C:\Users\myuser\AppData\Roaming\npm) in the Path variable.

@mads-hartmann
Copy link
Collaborator

@seflue Thanks for trying it out on Windows. You can see here how it tries to figure out where bash-language-server is installed. I'll see if I can add a settings where you can explicitly set the path to the bash-language-server executable so it's a bit easier to debug :)

@seflue
Copy link

seflue commented Mar 16, 2018

@mads-hartmann: Could you try both cases of command, bash-language-server and bash-language-server.cmd when creating the promise? The latter is the command for Windows and it needs the .cmd-Suffix for recognizing the script type, because ... Windows, you know? ;-) The first is the bash script used by Linux, which produces an error trying to be executed on Windows, so it concludes to the missleading error message, that the installation folder is not in the PATH.

@mads-hartmann
Copy link
Collaborator

@seflue Definitely. I should be able to detect if you're on windows or not and then use the cmd extension. If you're up for it you could try to work on the extension locally and use the .cmd extension to see if everything works then :)

@mads-hartmann
Copy link
Collaborator

@seflue I've published version 1.2.1 which adds .cmd if you're running on windows. I'd love if you could give it a go :)

@seflue
Copy link

seflue commented Mar 19, 2018

@mads-hartmann: I tried the new version, but I still get the same error. It would be nice if you can write out some error log, to check, what is going wrong when the plugin tries to execute the command.

@mads-hartmann
Copy link
Collaborator

@seflue Thanks for trying :) I'll add some more logging. Could you explain how you managed to install it on Windows? That would make it possible for me to debug it :)

@seflue
Copy link

seflue commented Mar 19, 2018

@mads-hartmann: I can't give you an exact recipe, but I fiddled around a little bit with the tips on the Internet. I ran npm install --global --production windows-build-tools on an administrator powershell and changed the msvs_version to 2015 with npm config set msvs_version 2015 --global also with administrator permissions. After some trying with these commands under different permissions (user and administrator) I was able to install bash-language-server successfully with npm i -g bash-language-server. It broke my BuildTools 2017 setup and cost me some time to get it up and running again, but I managed it somehow.

@henson-dev
Copy link

henson-dev commented Mar 22, 2018

Here's what I get:

C:\WINDOWS\system32>bash-language-server
Unknown command 'C:\Program Files\nodejs\node.exe C:\Users\User\AppData\Roaming\npm\node_modules\bash-language-server\bin\main.js'. Run with -h for help.

C:\WINDOWS\system32>bash-language-server.cmd
Unknown command 'C:\Program Files\nodejs\node.exe C:\Users\User\AppData\Roaming\npm\node_modules\bash-language-server\bin\main.js'. Run with -h for help.

Could you somehow be quoting the path of the program and the argument before calling it?

EDIT: Nevermind! I wasn't putting start after it..

@PromoFaux
Copy link

PromoFaux commented Apr 21, 2018

@mads-hartmann

I've published version 1.2.1 which adds .cmd

I may or may not be doing something wrong. Was unable to get it intsall on windows, so have installed on WSL and used the wsl-proxy method that was mentioned a few comments up... VSCode still complaining that it can't find bash-language-server on my PATH.. am I doing something wrong that is glaringly obvious?? :)

image

image

image

@PromoFaux
Copy link

Worth noting it works from cmd

image

@PromoFaux
Copy link

Getting somewhere, getBasePath() is falling over. Looks as though using the wsl-proxy doesn't work/isn't compatible. I'll keep digging.

image

@PromoFaux
Copy link

Lots of tinkering this afternoon, but didn't really get anywhere with it. It appears that attempting to run bash-language-server via the batch file that redirects it to WSL does not work too great.

I did, however, discover that you can get it working under WSL by using the Linux version of Code via an Xserver.

Bit of a hacky workaround I guess, but I'm satisfied with the outcome.

TL;DR - Compile bash-language-server on WSL, get linux Code working via WSL, this now "works on windows" 😉

@mads-hartmann
Copy link
Collaborator

@PromoFaux Thanks for documenting your attempts :) I hope it will help other people to get it to work on Windows, even if it is using WSL 👍

@rickywu
Copy link

rickywu commented Jul 2, 2019

should I use 'sh': ['bash-language-server', 'start']
or 'sh': ['bash-language-server.cmd', 'start']

bash-language-server start works well in cmd but not work when use in Vim

@dseynhae
Copy link

Since this is still open, and there doesn't seem to be a clear recipe confirmed:

  1. I experimented with different versions of NodeJS, and different distributors (e.g. https://chocolatey.org/packages/nodejs); However, the only one that led to a working solution is https://nodejs.org/en/, where I downloaded the installer for 10.16.3LTS. When I installed it, I made sure to select "Add to PATH", for easy access of the "npm" command.
    image.
    This installation went very easy, and there were no "dependencies" throwing in any monkey wrenches.

  2. I went ahead and launched a CMD-console with Administration privileges, and dared to execute:
    npm i -g bash-language server
    Again extremely smooth (any other version of NodeJS that I tried was insisting on installing Python2, installing Windows Build packages,... I had cleared those from my system, and this npm-based installation was able to create the bash-language-server without complaints...
    image

  3. In VS Code, I was now ready to install the Local User Extension Bash ID. The only thing to pay attention to is the Bash ID setting for the Path:
    image

If you use the command with the '.cmd' suffix, you're all set! If you use the one with out the suffix, you'll get the dreaded:
image

And I'm now using it locally, happily ever after.

@gerwinkramer
Copy link

Thanks @beltaurus ! I'm using NVM For Windows so I had to set the "Bash Ide: Path" setting to something like: C:\Users\MyUserName\AppData\Roaming\nvm\v10.16.3\bash-language-server.cmd (note "nvm\v10.16.3" instead of npm in the path) and now it works 👍

@skovhus
Copy link
Collaborator

skovhus commented Dec 13, 2019

With the new version (1.4.0) of the VS Code extension, we got rid of the manual npm install step of the bash-language-server. Hopefully, this will resolve npm installation issues. :)

The latest version of bash-language-server (the npm package) should also be easier to install.

Let me know if this solves the issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants