OmniSharp / omnisharp-vim

Vim omnicompletion (intellisense) and more for C#
http://www.omnisharp.net
MIT License
1.72k stars 168 forks source link

Installer fails on WSL 2 with syntax error #624

Closed gabrieljoelc closed 4 years ago

gabrieljoelc commented 4 years ago

With a fresh install of omnisharp-vim, I answer "yes" to install the roslyn server the first time and get this error:

/home/myuserpath/.vim/bundle/omnisharp-vim/installer/omnisharp-manager.sh: 28: /home/myuserpath/.vim/bundle/omnisharp-vim/installer/omnisharp-manager.sh: Syntax error: "elif" unexpected (expecting "then")

I have both curl and wget installed which isn't the issue anyway since it doesn't like the syntax for some reason.

I ran the body of get_latest_version() method directly in my terminal and it worked. 🤷‍♂️

I also tried running the script directly in the terminal and get the same error.

nickspoons commented 4 years ago

How strange.

Does the script get any further if you skip that function by passing in the version?

:OmniSharpInstall v1.37.0
nickspoons commented 4 years ago

What shell are you using in your WSL terminal?

gabrieljoelc commented 4 years ago

Does the script get any further if you skip that function by passing in the version?

Good idea on trying different version. i didn't try that. unfortunately, I get the same error with both:

:OmniSharpInstall v1.37.0

and from the docs about WSL limitations:

:OmniSharpInstall v1.35.2

What shell are you using in your WSL terminal?

I am using zsh:

$ zsh --version
zsh --version
zsh 5.3.1 (x86_64-debian-linux-gnu)
nickspoons commented 4 years ago

The script is invoked using /bin/sh - what is that linked to on your system? /bin/sh --version ?

nickspoons commented 4 years ago

@gabrieljoelc I just updated the script slightly and simplified the conditionals. Can you check to see whether your system likes this version any better?

gabrieljoelc commented 4 years ago

just tried latest with both versions above and got the same error.

oh interesting.sh --version isn't working:

/bin/sh --version
/bin/sh --version
/bin/sh: 0: Illegal option --

tried searching the interwebs for other ways to check sh version but haven't found it yet.

nickspoons commented 4 years ago

you could try ls -l /bin/sh too

axvr commented 4 years ago

Which Linux distro are you using in WSL2? Ubuntu?

gabrieljoelc commented 4 years ago

you could try ls -l /bin/sh too

~ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Jan 23  2017 /bin/sh -> dash
~ apt-cache policy dash
dash:
Installed: 0.5.8-2.4
Candidate: 0.5.8-2.4
Version table:
*** 0.5.8-2.4 500
500 http://deb.debian.org/debian stretch/main amd64 Packages
100 /var/lib/dpkg/status

Which Linux distro are you using in WSL2? Ubuntu?

~ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 9.5 (stretch)
Release:        9.5
Codename:       stretch
axvr commented 4 years ago

Odd, Dash is also the default shell on Ubuntu, so the script should work on Dash.

I found this Stack Overflow question which seems to be similar, so it could be caused by newline characters.

Maybe try removing and re-downloading OmniSharp-vim from inside WSL?

jeeeem commented 4 years ago

I also having this error. I try everything with coc, mono, translate_cygwin_ws; but I can't make it work. Using coc-omnisharp 1 Capture2 Capture3

Although now, for linting I use ALE but the auto-completion is still not there. Is there something I don't know that I should do to make it working for me? I want to learn unity and it's too hard for me to use other editors other than using (n)vim.

gabrieljoelc commented 4 years ago

this is embarrassing. :facepalm: i just used the same command given by @nickspoons in https://github.com/OmniSharp/omnisharp-vim/issues/506#issuecomment-561918936 (I opened that issue) and it worked.

i must have a systemic issue with my git configs. 😬

To be clear, here were the steps:

  1. Opened /home/myuserpath/.vim/bundle/omnisharp-vim/installer/omnisharp-manager.sh
  2. :w ++ff=unix on the file
  3. Reran the installer
axvr commented 4 years ago

@jeeeem, that seems to be a different issue, could you open a new issue for it instead.

nickspoons commented 4 years ago

Ha ha, how funny to see the same names in the thread, nearly a year later.

To quote myself from that thread:

Ah excellent, always nice to get a resolution!

nickspoons commented 4 years ago

@gabrieljoelc now that the installer ran for you, can you tell me if OmniSharp-vim is working correctly for you in WSL2? I haven't been able to test that environment yet, but I've heard one report of it not working - I'm really keen to learn whether it's WSL2 that is the problem for this other user, or if they have something else going on?

gabrieljoelc commented 4 years ago

@nickspoons i'll give it a go this week.

kalvinpearce commented 4 years ago

I am gonna say there is most likely something up with WSL2. I have tried many different combinations I could think of to get it working but no dice. I swapped it to WSL1 and suddently everything worked like a charm. I am happy to open an issue for this and work through what ever needs to be done to help out but I am quite new to vim-land and might need a bit of extra explaining for some things :)

Melandel commented 4 years ago

Oh ? I didn't have a problem with WSL2. omnisharp-roslyn got installed nicely from :OmniSharpInstall.

I swapped it to WSL1 and suddently everything worked like a charm

This tends to mean that the files were on the windows side. Were your source code on wsl or on windows?

I ran the command from a vim installed on the wsl2 side, on a file that was stored on the wsl2 side.