Closed racterub closed 8 years ago
@james50428: 你那張圖裡底下的 error message 極像是在告訴你,它沒被 compiled 過。
YouCompleteMe 不是純粹的 VimScript 組成的 plugin, 他的 source tree 裡有 components 是需要手動去 compile 的。 通常需要 compile 的時機為:第一次安裝、以及經過幾次 git pull 該 git repository 之後也可能會提示你需要 re-compile。 compile 動作…主要是跑它 source tree 底下那隻 install.py 檔。 (你可以執行 ./install.py --help 來查看它有哪些參數可用。) 詳細指令與過程可參考 官方 Installation 章節。
以下記錄些建置環境和 debug 的過程:
取得 Ubuntu 16.04 的 docker image。
$ docker run -it chusiang/vim-and-vi-mode:ubuntu16.04 bash
註解掉一些奇奇怪怪的錯誤。
root@74f3d0eb6e02:~# vim vimrc.old
YouCompleteMe unavailable: requires Vim compiled with Python (2.6+ or 3.3+) support
Press ENTER or type command to continue
root@74f3d0eb6e02:~# diff .vimrc vimrc.old
2,5c2,5
< "set rtp+=usr/local/lib/python2.7/dist-packages/powerline/bindings/vim
< "python from powerline.vim import setup as powerline_setup
< "python powerline_setup()
< "python del powerline_setup
---
> set rtp+=usr/local/lib/python2.7/dist-packages/powerline/bindings/vim
> python from powerline.vim import setup as powerline_setup
> python powerline_setup()
> python del powerline_setup
58c58
< "language message en_US.UTF-8
---
> language message en_US.UTF-8
142c142
< "colorscheme wombat
---
> colorscheme wombat
使用 vundle 安裝套件。
$ vim
:PluginInstall
跑完 vundle 時,出現 YouCompleteMe 的錯誤訊息如下。
YouCompleteMe unavailable: requires Vim compiled with Python (2.6+ or 3.3+) support
檢查 Python 版本,目前 docker container 測試環境預設使用的版本為 2.7.11。
root@74f3d0eb6e02:/tmp# python -V
Python 2.7.11+
查一下 dpkg,確定有預載到 Python 3.5。
root@74f3d0eb6e02:/tmp# dpkg -l | grep -E 'python2|python3'
移掉 vim 準備重譯。
root@74f3d0eb6e02:~# aptitude remove vim
參照 Building Vim from source · Valloric/YouCompleteMe Wiki、Vim 8.0 released, Install on Ubuntu 16.04 - Sysads Gazette - howto Guide, TechNew, Ubuntu, Open Source 和 Vim Compile | Austin Pray 等文件進行編譯。
$ sudo apt install -y ncurses-dev wget unzip gcc checkinstall \
libncurses5-dev libgnome2-dev libgnomeui-dev \
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \
python3-dev ruby-dev lua5.1 lua5.1-dev git cmake
$ unzip master.zip
$ cd vim-master/src
$ ./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp \
--enable-pythoninterp \
--with-python-config-dir=/usr/lib/python2.7/config \
--enable-python3interp \
--with-python3-config-dir=/usr/lib/python3.5/config \
--enable-perlinterp \
--enable-luainterp \
--enable-gui=gtk2 --enable-cscope --prefix=/usr
$ make VIMRUNTIMEDIR=/usr/share/vim/vim80
$ sudo make install
取得 vim 8.0。
root@74f3d0eb6e02:~# vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct 17 2016 18:35:55)
Included patches: 1-41
Compiled by root@74f3d0eb6e02
安裝 YouCompleteMe。
$ cd ~/.vim/bundle/YouCompleteMe
$ python install.py
跑完 YCM 的 install.py 還是會出現以下錯誤。
root@74f3d0eb6e02:~# vim
YouCompleteMe unavailable: requires Vim compiled with Python (2.6+ or 3.3+) support
最後還是不能用?看來得等 YCM 的大大出招了。
root@74f3d0eb6e02:~# nvim
YouCompleteMe unavailable: requires Vim compiled with Python (2.6+ or 3.3+) support
@james50428 試試看改用其它套件,別自己編囉,晚安啦!
還有哪天搞定了記得自己關 issue。
Goldie Lin: @chusiang: 那個「requires Vim compiled with Python (2.6+ or 3.3+) support」錯誤訊息,除了自行重新編譯 vim 之外,Ubuntu 有現成的替代套件可以裝:vim-nox 或 vim-nox-py2 (若偏好 python2 而不是python3 的話)。類似的套件還有 vim-gnome、vim-gnome-py2、…、等。
打算用vagrant惹,希望是這個問題QQ
Known issue 在原YCM的repo有人提報了(怎麼之前沒找到QQ 目前還沒試過 https://github.com/Valloric/YouCompleteMe/issues/2271
附上 @james50428 的環境建置 script。
如果只是想要自動補齊,沒有堅持要跑 YCM 的話,看要不要換 Vim Auto Complete Popup + vim-snipmate 的 solution。:P
我發現安裝 neovim 缺乏的 Python/Ruby binding libraries 就不再有那個 YouCompleteMe 錯誤訊息了。
# 也許你會需要加 sudo
gem install neovim
pip2 install neovim
pip3 install neovim
會發現是因為…在 nvim
底下執行了 :CheckHealth
指令,看到有缺乏元件的安裝提示才知道的。
health#nvim#check
================================================================================
## Remote Plugins
- SUCCESS: Up to date
## terminfo
- INFO: key_backspace terminfo entry: key_backspace=\177,
health#provider#check
================================================================================
## Python 2 provider
- WARNING: No Python interpreter was found with the neovim module. Using the first available for diagnostics.
- WARNING: provider/pythonx: Could not load Python 2:
/usr/bin/python2 does not have the neovim module installed. See ":help provider-python".
/usr/bin/python2.7 does not have the neovim module installed. See ":help provider-python".
python2.6 not found in search path or not executable.
/usr/bin/python does not have the neovim module installed. See ":help provider-python".
- INFO: `g:python_host_prog` is not set. Searching for python2 in the environment.
- INFO: Executable: /usr/bin/python2
- INFO: Python2 version: 2.7.6
- INFO: python2-neovim Version: unable to find nvim executable
- ERROR: Neovim Python client is not installed.
- SUGGESTIONS:
- Error found was: unable to find nvim executable
- Use the command `$ pip2 install neovim`
- WARNING: Latest Neovim Python client version: (0.1.10)
## Python 3 provider
- WARNING: No Python interpreter was found with the neovim module. Using the first available for diagnostics.
- WARNING: provider/pythonx: Could not load Python 3:
/usr/bin/python3 does not have the neovim module installed. See ":help provider-python".
python3.5 not found in search path or not executable.
/usr/bin/python3.4 does not have the neovim module installed. See ":help provider-python".
python3.3 not found in search path or not executable.
/usr/bin/python is Python 2.7 and cannot provide Python 3.
- INFO: `g:python3_host_prog` is not set. Searching for python3 in the environment.
- INFO: Executable: /usr/bin/python3
- INFO: Python3 version: 3.4.3
- INFO: python3-neovim Version: unable to find nvim executable
- ERROR: Neovim Python client is not installed.
- SUGGESTIONS:
- Error found was: unable to find nvim executable
- Use the command `$ pip3 install neovim`
- WARNING: Latest Neovim Python client version: (0.1.10)
## Ruby provider
- ERROR: Missing Neovim RubyGem
- SUGGESTIONS:
- Install or upgrade the neovim RubyGem using `gem install neovim`.
- INFO: Ruby Version: ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
- INFO: Host Executable: not found
- INFO: Host Version: not found
看到訊息中有提示我要安裝什麼,於是裝看看。
# 也許你會需要加 sudo
gem install neovim
pip2 install neovim
pip3 install neovim
然後重開 nvim
,發現 YouCompleteMe 不再報怨了。
再執行一次 :CheckHealth
指令看看。
health#nvim#check
================================================================================
## Remote Plugins
- SUCCESS: Up to date
## Python 2 provider
- INFO: `g:python_host_prog` is not set. Searching for python2 in the environment.
- INFO: Executable: /usr/bin/python2
- INFO: Python2 version: 2.7.6
- INFO: python2-neovim Version: 0.1.10
- SUCCESS: Latest Neovim Python client is installed: (up to date)
## Python 3 provider
- INFO: `g:python3_host_prog` is not set. Searching for python3 in the environment.
- INFO: Executable: /usr/bin/python3
- INFO: Python3 version: 3.4.3
- INFO: python3-neovim Version: 0.1.10
- SUCCESS: Latest Neovim Python client is installed: (up to date)
## Ruby provider
- SUCCESS: Found Neovim RubyGem
- INFO: Ruby Version: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
- INFO: Host Executable: /home/goldie/.gem/ruby/2.3.0/bin/neovim-ruby-host
- INFO: Host Version: 0.3.1
看來 :CheckHealth
是 NeoVim 才有的指令,又上了一課啊!
health#nvim#check
================================================================================
- ERROR: Failed to run healthcheck for "nvim" plugin. Exception:
Vim(let):E902: "python3" is not an executable
解決了QAQ 看來是Vundle的問題
用Vundle裝完要用以下指令
cd ~/.vim/bundle/YouCompleteme
git submodule update --init --recursive
就解決惹QQ
感謝各位QQ
我在裝 vim Vundle 時,YCM 會噴 error 給我。
請問一下要怎麼解決?
我的 vim 是從 source 裝的,不是從 apt 載下來。