ycm-core/ycmd

Ycmd server error.

Closed this issue · 29 comments

@ptrv @abingham @Valloric
OS: windows 7
Client: ycmd-emacs
I met this when coding in a .cpp file. What's more, It can't complete anything in .cpp file while It works in .py flie. In a .cpp file, sometimes I get correct candidates with using ycmd-display-completions command and sometimes get empty candidate which is incorrect. But, whether it has candidates or not, the company only completes nothing in .cpp file.
And, there is only Python 2.7 in my machine.

Error output
Ycmd server error: ycm_core library compiled for Python 2 but loaded in Python 3.

ptrv commented

We had a bug in emacs-ycmd regarding exit codes. Signals where treated the same way as exit codes, which led to wrong error messages. The issue has been fixed.
@moyotar Are you on the latest versoin of emacs-ycmd?

@ptrv
There are something different and exciting after I updated it to the latest version. Company can show candidates now. Though it works slowly, which can't be accepted . The error still exists and I found new output which may be helpful.

Error 1
File mode specification error: (file-error "Creating pipe" "too many open files")
Error while checking syntax automatically: (file-error "Creating pipe" "too many open files")
apply: Creating pipe: too many open files

Error 2
Ycmd server error: ycm_core library compiled for Python 2 but loaded in Python 3.

In a .h file, Company shows candidates with normal speed.

ptrv commented

I think this report mixes up multiple issues. Problems with company should not be reported here. It belongs to emacs-ycmd project. Also we need clear reproduction steps and more information for your issues. Version of ycmd and emacs-ycmd, some output from the ycmd server.

However, I also encountered the issue with too many open files. Restarting the server helped in that case.

As @micbou already stated in a different issue, the error

Ycmd server error: ycm_core library compiled for Python 2 but loaded in Python 3.

was casused by the ycmd server crashing but emacs-ycmd reporting wrong reason. This has been fixed in abingham/emacs-ycmd#353

So maybe you are still using a (cached) old version of emacs-ycmd?

I had used el-get-update to make it up-to-date yesterday. Is YCM automatical completion in a .py files without other settings?

To make it work finely in c/c++ file, I spend a few days. Now I set it to work in '.py' file only.

@ptrv
This error Creating pipe: too many open files still exists in .py file and I can't stop or start ycmd.

@ptrv @abingham @Valloric
This is a really disturbing problem, which make me must kill emacs process and restart it to continue. I need your help.

Error while checking syntax automatically: (file-error "Creating pipe" "too many open files")

ptrv commented

@moyotar We need some reproduction steps to say more about the problem.

Looks like the error is coming from flycheck. What checkers do you have enabled? How many buffers do you have open?

Can you run list-processes and post the output (when the error appears)?

Thanks for your patience and your time. Are there messages else that you need?

ptrv commented

You have a lot of curl processes running.

The c-runtime on windows has a limit of 512 open file processes (see here)

Could you try setting request-backend variable to url-retrieve in you config like this:

(setq request-backend 'url-retrieve)

Does it change anything?

It's really exciting! The error Creating pipe: too many open files is gone. It can't help work now, at least.
But it's much better if you can help me to solve this, which makes ycmd crash and need a few time to restart in c/c++ mode.
image

Error output:

Making url-show-status local to http 127.0.0.1:64316 while let-bound!
Mark set
error in process sentinel: open-network-stream: make client process failed: connection refused, :name, 127.0.0.1, :buffer, #, :host, 127.0.0.1, :service, 64316, :nowait, nil
error in process sentinel: make client process failed: connection refused, :name, 127.0.0.1, :buffer, #, :host, 127.0.0.1, :service, 64316, :nowait, nil
Ycmd server error: ycm_core library compiled for Python 2 but loaded in Python 3.

The pic above means python.exe has stopped working. The window will pop up if Ycmd server error happens.

This looks like a libclang crash, similar to issue #599. Could you attach the contents of your C/C++ file and your .ycm_extra_conf.py file that reproduce the crash?

Ycmd server error: ycm_core library compiled for Python 2 but loaded in Python 3.

This error should only happen at the start of ycmd when it fails to load the ycm_core library and exits with status code 6. I doubt this is the case here so maybe issue abingham/emacs-ycmd#352 was not completely resolved?

ptrv commented

With the fix in abingham/emacs-ycmd#352 we check explicitly for the process-status that Emacs is returning. Only when Emacs is returning an exit we print such error messages. So either @moyotar is still not using the latest emacs-ycmd version or emacs is giving wrong status information about the process.

Just now, I had used command el-get-update to update emacs-ycmd successfully. Then, I restarted emacs and tested. It worked normally in python-mode and didn't in c/c++-mode. I got these messages in c/c++-mode.

error in process sentinel: open-network-stream: make client process failed: connection refused, :name, 127.0.0.1, :buffer, #, :host, 127.0.0.1, :service, 62525, :nowait, nil
error in process sentinel: make client process failed: connection refused, :name, 127.0.0.1, :buffer, #, :host, 127.0.0.1, :service, 62525, :nowait, nil
error in process sentinel: open-network-stream: make client process failed: connection refused, :name, 127.0.0.1, :buffer, #, :host, 127.0.0.1, :service, 62525, :nowait, nil
error in process sentinel: make client process failed: connection refused, :name, 127.0.0.1, :buffer, #, :host, 127.0.0.1, :service, 62525, :nowait, nil
error in process sentinel: open-network-stream: make client process failed: connection refused, :name, 127.0.0.1, :buffer, #, :host, 127.0.0.1, :service, 62525, :nowait, nil
error in process sentinel: make client process failed: connection refused, :name, 127.0.0.1, :buffer, #, :host, 127.0.0.1, :service, 62525, :nowait, nil
Ycmd server error: ycm_core library compiled for Python 2 but loaded in Python 3.

I used list-process when seeing error in process sentinel. I got this.
image

ptrv commented

@moyotar Can you try this out this branch: https://github.com/ptrv/emacs-ycmd/tree/get-port-from-server (diff: abingham/emacs-ycmd@master...ptrv:get-port-from-server)

It looks like in your Emacs, generating random port with make-network-process does not work. With the patch from the branch mentioned above, we parse the port from the server output.

Or you can try also to set the server port manually (setq ycmd-server-port 12345)

Yes! I replaced emacs-ycmd with yours. Now, it works better. There is only a error left, which makes ycmd stop completion a few seconds frequently.

Ycmd server error: ycm_core library compiled for Python 2 but loaded in Python 3.

Oh! There's one thing I forgot to tell you. I don't know whether it's relative with this error or not. Before building ycmd-server, I edited one line in build.py. Because I only installed Visual Studio 10 in my machine.

image

@micbou It happens when in c/c++ mode and doesn't matter what contents.

My config:

(set-variable 'ycmd-global-config "D:/appdata/emacs/extraBin/ycmd/cpp/ycmd/.ycm_extra_conf.py")
(set-variable 'ycmd-extra-conf-whitelist '("E:/*"))

My c++ project is under E:\download\P2P-master\P2P-master.

This is my .ycm_extra_conf.py file in path E:\download\P2P-master. (Only difference shown here)

flags = [
'-std=c++11',
'-stdlib=libc++',
'-Wno-deprecated-declarations',
'-Wno-disabled-macro-expansion',
'-Wno-float-equal',
'-Wno-c++98-compat',
'-Wno-c++98-compat-pedantic',
'-Wno-global-constructors',
'-Wno-exit-time-destructors',
'-Wno-missing-prototypes',
'-Wno-padded',
'-x',
'c++',
'-I',
'.',
'-isystem',
'd:/appdata/emacs/extraBin/LLVM/include/clang-c',
'-isystem',
'd:/appdata/emacs/extraBin/LLVM/include/llvm-c',
'-isystem',
'D:/appdata/Microsoft Visual Studio 10.0/VC/include',
]

# try:
# final_flags.remove( '-stdlib=libc++' )
# except ValueError:
# pass
ptrv commented

Ycmd server error: ycm_core library compiled for Python 2 but loaded in Python 3

Hmm, this is strange. The server crashes but Emacs reports an exit. Needs investigation.

I have updated emacs-ycmd and still meet it. Please tell me once you have a solution.

error in process sentinel: open-network-stream: make client process failed: connection refused, :name, 127.0.0.1, :buffer, #, :host, 127.0.0.1, :service, 55411, :nowait, nil
error in process sentinel: make client process failed: connection refused, :name, 127.0.0.1, :buffer, #, :host, 127.0.0.1, :service, 55411, :nowait, nil
Ycmd server error: ycm_core library compiled for Python 2 but loaded in Python 3.

ptrv commented

@moyotar Your emacs-ycmd version is definitaly not up to date because we removed the function which could cause the error message with open-network-stream. Maybe you have still a byte compiled version around which gets loaded.

Please make sure you have the latest version. Maybe set (setq load-prefer-newer t)

Also it would be helpful if you could reproduce the problem with starting emacs with emacs -Q

Yes, I had still a byte compiled version. In rough test, it worked finely in c/c++ mode. It's pleasant! I will close this issue after confirming that the errors above don't exist any more. Thanks a lot!