paulluap
paulluap

Reputation: 311

How to debug/investigate issues with YouCompleteMe for Windows

UPDATE

This question seeks help with tooling - "how do I debug my problem." As I type this, there has been no answers. I did end up stumbling on the solution for the actual problem I was trying to solve and have provided the solution as an answer.

I still would be more than happy to hear any answers on the tooling question though, and if somebody comes up with a workable answer, I'll be more than happy to transfer the checkmark

Original Question

I initially opened an issue with YouCompleteMe https://github.com/Valloric/YouCompleteMe at https://github.com/Valloric/YouCompleteMe/issues/1345. It immediately got closed because there's no official support for Windows. Ok, fine.

I'm now asking the Stackoverflow community, hopefully there are people who are messing with YCM for Windows (there is a "unofficial YCM for Windows" page, so there MUST be SOMEBODY hacking on this thing).

Below is the original content of the issue that I opened.

If somebody actually has an answer that works, great! At this point, I'm looking more for procedures that I can use to run the YCM server under a debugger to see where exactly it's choking

I'm trying to get YCM to work on my Windows 7 machine. I have a few other XP, Win7, Win8 machines that have no problems with YCM. I've tried building the support stuff using MinGW, Visual Studio 2010, both on the target machine as well as the other machines where I have YCM working.

When I open a Python or C++ file, a message immediately appears that YCM has crashed and I should restart with :YcmRestartServer. It mentions that I should set g:ycm_server_keep_logfiles in order to see the log messages. I have done that, but I still don't have any logfiles and the "set g:ycm_server_keep_logfiles" message is still appearing.

I also get ('Connection aborted.', error(10061, 'No connection could be made because the target machine actively refused it'))

I looked in python\ycm\youcompleteme.py and saw that the "logfiles deleted" message comes up because of an exception in trying to open the file specified by self._server_stderr (IOError). Right now I'm suspecting that this is because the server never actually gets far enough in its startup sequence to actually create the stdout and stderr files.

What are the steps that I could do to investigate why the server (?) fails to start properly.

I also had a vague idea that there was a firewall rule blocking connections, I looked through Windows Firewall, but didn't really see anything that would point to localhost connections being blocked or whatnot.

I'm okay with doing debugging, would appreciate advice on the procedure that I would need to do in order to get Visual Studio 2010 to step into the server process and poke around stuff.

Oh, dunno if this factoid means anything, but I'm able to use Rip-Rip's clang_complete without issues, but I would very much rather use YCM.

Upvotes: 2

Views: 2199

Answers (1)

paulluap
paulluap

Reputation: 311

I never really did get an answer or solution to the central question of "how do I debug YCM under Windows" but I did solve the underlying problem of why YCM wasn't working for me, so for posterity (and other fellow despairing YCM users who may end up here via Google)

For me, YCM immediately crashed and burned. I figured the problem out by seeing a Windows system that had been working fine for me start exhibiting the symptoms.

The change: I had installed Python 3.x and switched it to being the system preferred python (by messing with paths, what do you expect with Windows?).

As it turns out (duh), YCM depends on Python 2.x and falls over when it can't find any of the libraries that it was trying to open.

I started going down the path of trying to locate exactly what the files YCM was trying to access and provide them locally in the YCM directory, but after spending five minutes on it, I decided that I wanted something simpler.

Since I still wanted Python 3.x to be the 'system' version, I settled for manipulating the path WITHIN Vim, so I added this before the YCM load,

if (has('win32') || has('win64'))
    let $PATH = 'C:\Python27;' . $PATH
endif

Hope that this saves somebody else some pain

Upvotes: 2

Related Questions