OmniSharp / omnisharp-vim

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

Message: Internal Error - System.ArgumentException: OmniSharp only supports being launched with a directory path or a path to a solution (.sln) file. #685

Closed ghost closed 3 years ago

ghost commented 3 years ago

Sory for my bad english. I install vim on cygwin and trying install omnisharp, but everytime when i edit .cs file i get this error. I saw other similar posts, but this dont help me. I'm using dotnet and omnisharp. In log path it looks like omnisharp find my solution(.sln) file and start but he doesnt find, i think. Chanel 0 open: 'System.ArgumentException: OmniSharp only supports being launched with a directory path or a path to a solution (.sln) file.' and other. I dont know how i can copy my message in vim.

nickspoons commented 3 years ago

If you're in cygwin, I assume dotnet is installed as a Windows install, not Linux? And you're using normal Windows msbuild etc.? Then you need to make sure you have let g:OmniSharp_translate_cygwin_wsl = 1 in your .vimrc

We can't guess what your config or project structure look like. Please post your .vimrc and :OmniSharpLog

ghost commented 3 years ago

Yes i installed dotnet as a Windows installer, i did translate my cygwin

:OmniSharpLog - it print: e492:'not an editor command' PythonLog is empty and everytime when i try :OmniSharpStartServer new file added in folder 'log' with name like '202103011913_1867_omnisharp.log' and the same:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 30 2020 21:58:19), Included patches: 1-486

OmniSharp server started.
    Path: /cygdrive/c/Users/secre/AppData/Local/omnisharp-vim/omnisharp-roslyn/OmniSharp.exe
    Target: /code/Csharp/mysolution.sln
    PID: 1867
    Command: /cygdrive/c/Users/secre/AppData/Local/omnisharp-vim/omnisharp-roslyn/OmniSharp.exe -p 49550 -s \code\Csharp\mysolution.sln -l warning -e utf-8

.vimrc:

call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree'
Plug 'OmniSharp/omnisharp-vim'
Plug 'tomasiser/vim-code-dark'
Plug 'vim-airline/vim-airline'
call plug#end()

"COLORSCHEME
syntax on
set t_Co=256
colorscheme codedark
set guifont=Semi-bold
set keymap=russian-jcukenmac
"Язык ввода при старте Вима - Английский
set iminsert=0
"Аналогично настраивается режим поиска
set imsearch=0

autocmd vimenter * NERDTree

"NERDTREE
map <C-n> :NERDTreeToggle<CR>

"OMNISHARP
inoremap <expr> <Tab> pumvisible() ? '<C-n>' :                                                                                                                    
\ getline('.')[col('.')-2] =~# '[[:alnum:].-_#$]' ? '<C-x><C-o>' : '<Tab>'
nnoremap <C-o><C-u> :OmniSharpFindUsages<CR>
nnoremap <C-o><C-d> :OmniSharpGotoDefinition<CR>
nnoremap <C-o><C-d><C-p> :OmniSharpPreviewDefinition<CR>
nnoremap <C-o><C-r> :!dotnet run
let g:OmniSharp_translate_cygwin_wsl = 1
let g:OmniSharp_proc_debug = 1
let g:syntastic_cs_checkers = ['code_checker']
let g:OmniSharp_server_stdio = 0
let g:ale_linters = {
\ 'cs': ['OmniSharp']
\}

"AIRLINE
let g:airline_powerline_fonts = 1 "Включить поддержку Powerline шрифтов
let g:airline#extensions#keymap#enabled = 0 "Не показывать текущий маппинг
let g:airline_section_z = "\ue0a1:%l/%L Col:%c" "Кастомная графа положения курсора
let g:Powerline_symbols='unicode' "Поддержка unicode
let g:airline#extensions#xkblayout#enabled = 0 "Про это позже расскажу
let g:airline_theme = 'codedark'    

let &pythonthreedll = 'C:\Users\secre\bin\libpython3.6m.dll'
let solution_path = substitute('C:\Users\secre\code\Csharp\mysolution.sln', '\home\secre\', '\Users\secre\', 'g')
nickspoons commented 3 years ago

Sorry, that command should be :OmniSharpOpenLog

nickspoons commented 3 years ago

Remove these lines:

let g:OmniSharp_proc_debug = 1
let g:syntastic_cs_checkers = ['code_checker']
let g:OmniSharp_server_stdio = 0

Where did you get these from?

ghost commented 3 years ago

:OmniSharpOpenLog return -

Error detected while processing function OmniSharp#log#Open[10]..OmniSharp#py#Eval:
line 1:
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'getLogFile' is not defind
nickspoons commented 3 years ago

See my edits to the previous comment

ghost commented 3 years ago

Ok, i'm checking it right now

ghost commented 3 years ago

i reinstall Omnisharp without let g:OmniSharp_server_stdio = 0 (and others) and it give me the same error

ghost commented 3 years ago

:OmniSharpOpenLog:

2021-03-01 23:32:54,072 ERROR Could not connect to OmniSharp server: http://localhost:49503/checkalivestatus
Traceback (most recent call last):
  File "/usr/lib/python3.6/urllib/request.py", line 1349, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.6/http/client.py", line 1287, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1333, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1282, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1042, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 980, in send
    self.connect()
  File "/usr/lib/python3.6/http/client.py", line 952, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.6/socket.py", line 726, in create_connection
    raise err
  File "/usr/lib/python3.6/socket.py", line 715, in create_connection
    sock.connect(sa)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/secre/.vim/plugged/omnisharp-vim/python/omnisharp/util.py", line 220, in doRequest
    response = opener.open(req, body, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 1377, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.6/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error timed out>
nickspoons commented 3 years ago

That's the HTTP server. You need to reinstall and use the stdio server.

nickspoons commented 3 years ago

And your OmniSharp-vim is still trying to run in HTTP mode.

ghost commented 3 years ago

Now, i remove omnisharp and install with let g:OmniSharp_server_stdio = 1, but the same problem :OmniSharpOpenLog:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 30 2020 21:58:19), Included patches: 1-486

OmniSharp server started.
    Path: /cygdrive/c/Users/secre/AppData/Local/omnisharp-vim/omnisharp-roslyn/OmniSharp.exe
    Target: /code/Csharp/mysolution.sln
    PID: 1535
nickspoons commented 3 years ago

I think OmniSharp-vim is trying and failing to translate your cygwin path into a Windows path. /code/Csharp/mysolution.sln is a bit of an unusual format isn't it? Is this a custom cygwin prefix you are using? This plugin tries to translate paths in this format:

/cygdrive/c/whatever

into this format:

C:\whatever
ghost commented 3 years ago

I did not think about this problem, thank you for this, but i don't know how i can fix it?

ghost commented 3 years ago

i did (mount --change-cygdrive-prefix / ) but i think that is not it

nickspoons commented 3 years ago

It's been a long time since I used cygwin (I use WSL these days), I'm not entirely sure how to do it, but on my system it has always used /cygdrive/c/... by default

ghost commented 3 years ago

Maybe i should change path for my project, add this in home folder in cywgin? or somehow add it in system enviroment?

nickspoons commented 3 years ago

Oh so your code is inside the cygwin file system? I would expect your project to be located on the windows file system somewhere, e.g. C:\code\project, then you get to it in cygwin with cd /cygdrive/c/code/project and vim sometime.cs

ghost commented 3 years ago

Maybe i wrote wrong, but you was right my project located in C:\Users\username\code\Csharp

ghost commented 3 years ago

But i dont know what i should do now, you say that problem with prefix and i dont know how i can fix it. I'm trying search something like "how change prefix in cygwin".

ghost commented 3 years ago

https://github.com/OmniSharp/omnisharp-vim/issues/414#issuecomment-426472393 i think maybe this similar to my problem, but i don't know what mean: "OmniSharp#util#get_start_cmd" , i should add this: "let solution_path = substitute(solution_path, '/home/mate/', '/Users/mate/', 'g')" in my .vimrc or it will not work?

ghost commented 3 years ago

EEEE, that work i think, but i don't know how i can check it i add: let solution_path = substitute('cygdrive/c/Users/mate/code/Csharp/mysolution.sln', '/home/mate/', '/Users/mate/', 'g') Now when i open my .cs file i have no problem, i think. Thank you. Now i need guide for using omnisharp

nickspoons commented 3 years ago

This line let solution_path = substitute('cygdrive/c/Users/mate/code/Csharp/mysolution.sln', '/home/mate/', '/Users/mate/', 'g') is not doing anything in your .vimrc, the user in the comment you linked was altering the plugin code. So you can safely remove that line.