OmniSharp / omnisharp-vim

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

Can't run omnisharp-roslyn (macOS) #832

Open frarees opened 1 year ago

frarees commented 1 year ago

MacVim on Ventura 13.1.

DEBUG: 'Using vim job_start to start the following command:'
DEBUG: ['/Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/run', '-s', '/Users/frarees/Developer/Unity/sandbox/sandbox.sln',  '-l', 'debug', '-e', 'utf-8']
Could not run command: /Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/run -s /Users/frarees/Developer/Unity/sandbox/sandbox.sln -l debug -e utf-8 

Invoking

/Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/run -s /Users/frarees/Developer/Unity/sandbox/sandbox.sln -l debug -e utf-8 

On terminal works fine. Any ideas?

nickspoons commented 1 year ago

No, not really. Can you run that command from inside macvim with :!...? Or, the same way omnisharp-vim runs it:

:call job_start(['/Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/run', '-s', '/Users/frarees/Developer/Unity/sandbox/sandbox.sln'', '-e', 'utf-8'], #{out_cb: {_,m->execute('unsilent echom ' . string(m))}})
frarees commented 1 year ago

Copy-pasted your command. It returns:

E121: Undefined variable: e
E116: Invalid arguments for function job_start 

Invoking through :!... gave me this tho:

/Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/run: line 19: mono: command not found

shell returned 127

mono is in my path (installed via brew --cask):

frarees@MBP18 ~ % which mono
/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono
nickspoons commented 1 year ago

Well if you can run /Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/run from the command line but not from vim, then it looks like the way your path is set up.

Can you run :!which mono from inside vim?

nickspoons commented 1 year ago

Copy-pasted your command.

Oops, I had an extra ' in there, the actual command is:

:call job_start(['/Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/run', '-s', '/Users/frarees/Developer/Unity/sandbox/sandbox.sln', '-e', 'utf-8'], #{out_cb: {_,m->execute('unsilent echom ' . string(m))}})
frarees commented 1 year ago

Tried your command, gives me no output this time.

!which mono says mono not found tho. Huh

nickspoons commented 1 year ago

Oh yeah since it is erroring, we should include the error output in the command:

:call job_start(['/Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/run', '-s', '/Users/frarees/Developer/Unity/sandbox/sandbox.sln', '-e', 'utf-8'], #{out_cb: {_,m->execute('unsilent echom ' . string(m))}, err_cb: {_,m->execute('unsilent echom ' . string(m))}})

That will probably output the "mono not found" message again

nickspoons commented 1 year ago

So how are you adding mono to your path? Does brew do it itself? Or do you do it in e.g. a .bashrc or something? Because a .bashrc won't be being sourced from within vim, it'd need to be in something like .profile or .bash_profile. I use zsh and set environment variables like path in .zshenv, not .zshrc

nickspoons commented 1 year ago

You've been using omnisharp-vim from macvim for a long time though - have you changed something in your config? It used to work for you (according to our previous discussions).

frarees commented 1 year ago

I've been using VimR for years now, trying MacVim again since I've formatted my laptop. So it's likely that my setup has changed.

I see that it's defined in /etc/paths.d/mono-commands.

I've noticed it could be a problem of macOS' open behaviour:

I open the app using https://docs.unity3d.com/ScriptReference/Unity.CodeEditor.CodeEditor.OSOpenFile.html, which is not the usual Process.Start(). This is how I had it coded back in the day when I used MacVim.

For what it's worth, this seems not to be a omnisharp-vim issue (although it could do a better job at informing this? I didn't get any output until I enabled debug mode), so I'll keep digging see why MacVim is not getting env vars inherited.

nickspoons commented 1 year ago

Do you want to try to comment out these lines, and see if you get good warnings when you load macvim?

https://github.com/OmniSharp/omnisharp-vim/blob/master/autoload/OmniSharp/proc.vim#L109-L111

Those lines were added to prevent warnings after a job was stopped, but they are possibly also the issue here.

nickspoons commented 1 year ago

Oh funny, I added the error suppression for closed channels as a result of another of your issues, #629

frarees commented 1 year ago

Is it possible to specify the mono path at vimrc level?

nickspoons commented 1 year ago

No. We specify run the path to the run script, which sets mono to mono from your path, we can't do more from this side.

https://github.com/OmniSharp/omnisharp-roslyn/blob/master/mono-packaging/run