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

Installing YCM with Yosemite and brew vim #1136

Closed
TheZoc opened this issue Aug 27, 2014 · 10 comments
Closed

Installing YCM with Yosemite and brew vim #1136

TheZoc opened this issue Aug 27, 2014 · 10 comments

Comments

@TheZoc
Copy link

TheZoc commented Aug 27, 2014

Hello,

This isn't really an issue (maybe except for build.sh search path, noted below), but I'd like to share the process I used to install a working YCM with the homebrew version of vim and system clang.
I didn't manage to get it to work with the default installation parameters, so, I thought this might help some people out there.

This isn't a step by step on how I figured out what I need to do, but rather a streamlined version of how to get everything working.

When trying to run: ./install.sh --clang-completer --omnisharp-completer, it downloads clang 3.4 and the installation fails.
Also, trying to run ./install.sh --clang-completer --omnisharp-completer --system-libclangfails because it can't find libclang.dylib

Lets get some info:

❯❯❯ mdfind -name libclang.dylib
/Library/Developer/CommandLineTools/usr/lib/libclang.dylib

It exists. So, this shouldn't be a problem. Also, lets check the version of system clang:

❯❯❯ clang --version
Apple LLVM version 6.0 (clang-600.0.47) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

It's newer than the required version, it's supposed to work fine.

So, you need to modify the file: ~/.vim/bundle/YouCompleteMe/third_party/ycmd/build.sh"
and change the line: cmake_args="$cmake_args -DUSE_SYSTEM_LIBCLANG=ON"
to: cmake_args="$cmake_args -DEXTERNAL_LIBCLANG_PATH=/Library/Developer/CommandLineTools/usr/lib/libclang.dylib". Please note that this change is the output of mdfind -name libclang.dylib.

Note: I noticed that build.sh search for the lib in that path. Still, it didn't find it. I'm not sure why.

Installing now works flawlessly.

Last but not least, my vim was installed with python3 support. I had to replace it with python (2.x) support.
I really would like to keep it supporting python3, but I'm happy trading that for an IntelliSense-like functionality.
(Hopefully a future version of YCM will support both versions of python)

So the entire process to get YCM working with homebrew's vim + Yosemite would be:

xcode-select --install
brew update
brew upgrade
brew install python
brew install vim --with-perl --override-system-vi --HEAD
brew install cmake

I also did in this step:

pip install fluke8
pip install nose

Okay, so at this point you install YCM through Vundle. Once it's done, edit ~/.vim/bundle/YouCompleteMe/third_party/ycmd/build.sh" with above changes

Then run:

./install.sh --clang-completer --omnisharp-completer --system-libclang

And you're done!

Please note that run_tests.shwill still fail to find the correct dylib.

I hope this helps someone out there!

Also, I'd love to ask to @Valloric - What's the correct way of fixing build.sh so it searches for the correct dylib automatically, instead of doing this modification of build.sh?

Thank you for your excellent work on YCM! 😀

@Valloric
Copy link
Member

Since you just want to change the cmake args the build process uses, you can set the EXTRA_CMAKE_ARGS environment variable to whatever extra arguments you want to pass.

This would work for your use-case:

EXTRA_CMAKE_ARGS="-DEXTERNAL_LIBCLANG_PATH=/Library/Developer/CommandLineTools/usr/lib/libclang.dylib" [./install.sh with whatever flags you want]

Last but not least, my vim was installed with python3 support. I had to replace it with python (2.x) support. I really would like to keep it supporting python3

Sadly you can't have both python2 and python3 support compiled into Vim. Since basically all Vim plugins that use Python use python2, that's what you should use.

Thanks for posting your experience; people coming from Google will appreciate it.

Closing issue.

@TheZoc
Copy link
Author

TheZoc commented Aug 27, 2014

Thanks for the quick reply @Valloric! :)

One thing that I should point out is that I tried to initially use this:

cmake_args="$cmake_args -DUSE_SYSTEM_LIBCLANG=ON -DEXTERNAL_LIBCLANG_PATH=/Library/Developer/CommandLineTools/usr/lib/libclang.dylib"

But it fails to build.

@Valloric
Copy link
Member

I don't remember the details, but I doubt you can set both USE_SYSTEM_LIBCLANG and EXTERNAL_LIBCLANG_PATH; such a combination of flags doesn't really make any sense. One says "go look for the libclang in system dirs" while the other says "use this libclang I gave you." They can't both work at the same time.

@TheZoc
Copy link
Author

TheZoc commented Oct 20, 2014

Sorry to revive this, but on Yosemite final build, I tried to:

EXTRA_CMAKE_ARGS="-DEXTERNAL_LIBCLANG_PATH=/Library/Developer/CommandLineTools/usr/lib/libclang.dylib"

and

./install.sh --clang-completer --omnisharp-completer --system-libclang

and I get

Make Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
TEMP
    linked by target "ycm_core" in directory /Users/zoc/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm

-- Configuring incomplete, errors occurred!
See also "/var/folders/37/w2gq4hr159bcpr201xjjsgrh0000gn/T/ycm_build.XXXXXX.22XwoeIu/CMakeFiles/CMakeOutput.log".

Editing build.sh as I said in initial post allows me to build and execute YouCompleteMe successfully :)

Hope it helps someone out there (and hopefully have this issue fixed soon 👍 )

@Valloric
Copy link
Member

I think I found the reason why ./install.sh --clang-completer --omnisharp-completer --system-libclang failed for you on Yosemite (should be fixed now). Could you try it again? Make sure you run this without any local changes, just with a vanilla YCM checkout.

@TheZoc
Copy link
Author

TheZoc commented Oct 20, 2014

Sure, as soon as I arrive home I'll do it! Thank you for taking your time and looking into this :D

@TheZoc
Copy link
Author

TheZoc commented Oct 21, 2014

It works! Removing that comma did the trick! 😁
Thank you! 👍

@mbarakatt
Copy link

Thanks a lot TheZoc. I finally got it to work with your instructions!

@TheZoc
Copy link
Author

TheZoc commented Nov 25, 2014

@mbarakatt Glad it helped you :)
But, I'm curious, which issue did you run into ?
On my system, all issues were fixed since Oct 21th.

@mbarakatt
Copy link

It could actually be many things. Initially I ran into the ycm server crashing. Then played around, but only made it worst, I was getting vim to crash when it launched ('error' 6 or something like that ) . My guess is that is was probably linked with libclang and the fact that I just switched to yosemite. Had to reinstall the Command line tools..

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants