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

error initializing omnisharp-roslyn server #800

Open
PowaBanga opened this issue Aug 6, 2022 · 8 comments
Open

error initializing omnisharp-roslyn server #800

PowaBanga opened this issue Aug 6, 2022 · 8 comments

Comments

@PowaBanga
Copy link

PowaBanga commented Aug 6, 2022

Hi everybody,
I am trying to use omnisharp-vim for the first time, so i am on Archlinux, and i installed it on my system from this aur package : https://aur.archlinux.org/packages/omnisharp-vim-git

Now i when i open my .cs file vim ceasar/Program.cs , vim say this to me :

"ceasar/Program.cs" [dos] 36L, 1011B
The OmniSharp server does not appear to be installed. Would you like to install it?
(Y)es, [N]o: 

I type y and it told me every time :

"ceasar/Program.cs" [dos] 36L, 1011B
The OmniSharp server does not appear to be installed. Would you like to install it?

Installing OmniSharp Roslyn, please wait...
Error detected while processing BufRead Autocommands for "*.cs"..FileType Autocommands for "*"..function <SNR>20_LoadFTPlugin[18]
..script /usr/share/vim/vimfiles/ftplugin/cs/OmniSharp.vim[7]..function OmniSharp#StartServerIfNotRunning[5]..OmniSharp#StartServ
er[50]..<SNR>99_StartServer[7]..OmniSharp#util#GetStartCmd[23]..OmniSharp#Install:
line   47:
E482: Can't create file /usr/share/vim/vimfiles/log/install.log
Press ENTER or type command to continue

first, i think, it's strange that it want to create a log file in /usr/share, because i am not in root !
I didn't found package who contain this file.

so i tried to run vim in root, to see... sudo vim ceasar/Program.cs
and after typed y to install omnisharp server, i recieve this message :

"ceasar/Program.cs" [dos] 36L, 1011B
The OmniSharp server does not appear to be installed. Would you like to install it?

Installing OmniSharp Roslyn, please wait...
Failed to install the OmniSharp-Roslyn server
/bin/sh: /usr/share/vim/vimfiles/installer/omnisharp-manager.sh: No such file or directory
The full error log can be found in the file:  /usr/share/vim/vimfiles/log/install.log
Could not run command: /root/.cache/omnisharp-vim/omnisharp-roslyn/run -s /home/powabanga/Modèles/DevOp/Pedro/devoirs/ceasar/ceas
ar/ceasar.sln -e utf-8
Press ENTER or type command to continue

Does anybody can help me to find what did i wrong or what should i do to run it without issues? Please.

@nickspoons
Copy link
Member

It looks like that AUR package installs OmniSharp-vim under /use/share, so that's where the plug-in tries to write log files, but it doesn't have permission.

I don't have any experience with using distro package managers to install vim plugins, it's much more common to use a vim plugin manager such as vim-plug. This will result in the plug-in being located in a location where it has write access. After all, vim plugins are simply scripts, not binaries.

@PowaBanga
Copy link
Author

yep, your right about the write access. but only when i run it as user.

What about run it as root user ? this should work no ?

@nickspoons
Copy link
Member

I believe the actual answer here is "never run vim as root". Use vim -e or sudoedit, which allows you to use vim (assuming you have $EDITOR/$VISUAL/SUDO_EDITOR pointing at vim) with your personal config to edit a protected file in a safe way.

However I can't really imagine any scenario where you would want to run an elevated vim against a C# file?

@PowaBanga
Copy link
Author

PowaBanga commented Aug 6, 2022

Maybe I am making a mistake... my question is like : Does anybody can help to do or fix that ? I receive your answer a few like Why ? Don't do that guy, you do not need. ...

Maybe i am wrong, but i think that if a guy did a system package with this plugin, probably that he managed to make it work...

The idea is to edit the /etc/vimrc. Because of that all user in my system will have the config as default. And the only proper way to do this is to install the plugin with the package manager and edit the /etc/vimrc file... So, it's not for use vim to edit C# files in root. If it's that you understood, so yeah, the idea is probably a few crazy... It's not what i do.

... I just tested it to see if the bug persist in root or not... I use vim every day in root to edit my systems configuration because i am my own admin, and that vim is amazing to edit system configs... Why do you suggest to me to use sudoedit or vim -e exactly ???

@nickspoons
Copy link
Member

Maybe i am wrong, but i think that if a guy did a system package with this plugin, probably that he managed to make it work...

I don't know who made the system package or what this configuration was. I didn't make it, and they didn't consult with me. My recommendations as the plugin maintainer on how to install and use this plugin are the ones I've described here and in the README.

When you've asked about how to use this plug-in as root, my only answer can be that I don't intend to support that use case as it doesn't make sense for this plugin.

Why do you suggest to me to use sudoedit or vim -e exactly ???

I'm trying to explain why I would never have done that, or will support this usage.

@nickspoons
Copy link
Member

nickspoons commented Aug 6, 2022

Try adding let g:OmniSharp_log_dir = '/var/log/omnisharp' to your config, or some other location you have write access to. Your error is occurring because OmniSharp-vim is trying to write logs in a location that it doesn't have write permissions for.

The above should get you past the first error. Whether you'll get a correctly installed server after that, I don't know. I can't test currently, I'm mobile only, on holiday.

@PowaBanga
Copy link
Author

Ok, I think we misunderstood each other
Thank you for being constructive, it's nice.

So, here is how i fixed it :

  1. Add this line into /etc/vimrc
    let g:OmniSharp_log_dir = '/home/powabanga/.vim/'
    It can be changed into an other folder... Idealy it should be nice that we can disable logs, or set it relativly to the user/.vim or .cache folder.
    I know that on all linux systems, every users can writte into /tmp folder. Maybe it's a bad idea, (i do not know), but maybe that if the path is not specified, omnisharp-vim should be able to create it in this place... 🤔

  2. Omnisharp-vim plugin look for my roslyn server into /home/powabanga/.cache/omnisharp-vim/omnisharp-roslyn/run
    On my system, when omnisharp is installed with package, it is here : /usr/bin/omnisharp
    the problem here is that when i set this option in my vimrc :
    let g:OmniSharp_server_install = '/usr/bin/omnisharp'
    omnisharp-vim plugin do not find my omnisharp server because it is trying to run this: /usr/bin/omnisharp/run at the place of this /usr/bin/omnisharp
    So i fixed it by making a symbolic link ln -s /usr/bin/omnisharp /home/powabanga/.cache/omnisharp-vim/omnisharp-roslyn/run
    Here, maybe it should be good that we can specify the exact runner path/name

I do not know if there is a way to change this parameters on the build of omnisharp-vim plugin, they are script as you told it... but if it's possible, it can be a way to fix this too permanently 🙂

I'm on vacation too, especially enjoy it. Take care of that when you're not on vacation anymore. 🙂

Sincerely.
Powa

@nickspoons
Copy link
Member

g:OmniSharp_server_install is the location where OmniSharp-vim will try to install a server, and so treats that setting as a directory. You should use let g:OmniSharp_server_path = '/usr/bin/omnisharp' to set a specific server executable location.

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