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

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

Open
frarees opened this issue Feb 2, 2023 · 13 comments
Open

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

frarees opened this issue Feb 2, 2023 · 13 comments

Comments

@frarees
Copy link
Contributor

frarees commented Feb 2, 2023

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
Copy link
Member

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
Copy link
Contributor Author

frarees commented Feb 2, 2023

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
Copy link
Member

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
Copy link
Member

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
Copy link
Contributor Author

frarees commented Feb 2, 2023

Tried your command, gives me no output this time.

!which mono says mono not found tho. Huh

@nickspoons
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Contributor Author

frarees commented Feb 2, 2023

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:

  • When I open MacVim using open (or just, double-click the app), which mono returns fine
  • When I open MacVim via Unity, seems it's not inheriting env vars properly?

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
Copy link
Member

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
Copy link
Member

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

@frarees
Copy link
Contributor Author

frarees commented Feb 6, 2023

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

@nickspoons
Copy link
Member

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

nickcharlton added a commit to nickcharlton/dotfiles that referenced this issue Dec 12, 2023
This uses the .NET 6 (and above) native .NET, rather than configuring
Mono. To do this, we need to configure OmniSharp and also ensure
`DOTNET_ROOT` is set correctly for everything to work.

OmniSharp/omnisharp-vim#832
https://stackoverflow.com/a/72225758
https://stackoverflow.com/a/73896444
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants