Youcompleteme: No .ycm_extra_conf.py file detected

Created on 7 Jul 2013  ·  12Comments  ·  Source: ycm-core/YouCompleteMe

No .ycm_extra_conf.py file detected, so no compile flags are available. Thus no semantic support for C/C++/ObjC/ObjC++. Go READ THE DOCS _NOW_, DON'T file a bug report.
I have found the file ~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py。。
why?

Thanks a lot!
homilinx

Most helpful comment

I agree that YCM's documentation is a bit fuzzy. Basically, you have two options:

  • Add this line to your .vimrc after loading YCM. This sets a default location for .ycm_extra_conf.py. I believe this should have been the default for YCM.
let g:ycm_global_ycm_extra_conf = '$USER/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
  • Copy YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py to your source code directory and modify it if you need. This file will override the previous global extra conf file.

All 12 comments

Please read the error message again.

The documentation is clear. Please ensure that you are civil when interacting eith the volunteers here. Please see the code of conduct

I agree that YCM's documentation is a bit fuzzy. Basically, you have two options:

  • Add this line to your .vimrc after loading YCM. This sets a default location for .ycm_extra_conf.py. I believe this should have been the default for YCM.
let g:ycm_global_ycm_extra_conf = '$USER/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
  • Copy YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py to your source code directory and modify it if you need. This file will override the previous global extra conf file.

I agree that YCM's documentation is a bit fuzzy

Let's agree to disagree at least :P Is true that we work on this long enough that we can't always see the forest for the trees, so PRs are welcome :+1:

  • Add this line to your .vimrc after loading YCM. This sets a default location for .ycm_extra_conf.py. I believe this should have been the default for YCM.
let g:ycm_global_ycm_extra_conf = '$USER/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra

I don't know how many times I've written this, but DON'T DO THIS. Doing this you're basically using the settings that we use to work on the cpp side of ycmd for _your_ project, which I'm almost sure they're not the same.

Copy YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py to your source code directory and modify it if you need. This file will override the previous global extra conf file.

IMHO would be easier to write it from scratch, I mean:

def FlagsForFile(filename, **kwargs):
  flags = [ ... ] # put your flag here
  return { 'flags': flags }

@vheon what's the problem with supplying a global .ycm_extra_conf.py?
I came from Java & especially Python, thus I'm new to C++, so could you explain why one should want different flags for every project?
I mean you compile YCM once, right? And I am compiling my C++ projects with g++, so YCM has nothing to do with project-related compilation?! Why should YCM need project-related information/flags at all?

I came from Java

Let's see... do you use the same pom.xml for every Java project? I don't think so because maybe in one project you need Guava and in another one you need Solr; maybe in a project you have the file in a src directory and in another one you put the files in libs or whatever. Is the same in C++, hence you need different flags for every project. We don't need the flags for YCM itself, but we need the flags of your project to pass them to libclang to compile your code and provide you semantic completion and features. There is no universal flags set for every project in every language.

Ok, thanks for the explanation.

@mjdousti Your solution almost worked for me. Replacing $USER with a tilde (~) character to represent the path to the home directory instead did work, like so:

let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'

@cedarmora you should not do that. Read the docs to understand why.

@vheon Can you explain for me why do I need flags for project? And why don't we fix this problem with let command? I have just use it and I see it done. And I don't know why my .ycm_extra_conf.py not in cpp. It's just in ycmd folder and I don't have cpp folder. Sorry for this trouble. Thank you so much.

@PhamHoangNamAnh
Read this and the following two comments: https://github.com/Valloric/YouCompleteMe/issues/415#issuecomment-323601172

Was this page helpful?
0 / 5 - 0 ratings