読者です 読者をやめる 読者になる 読者になる

mabulog

このブログは、mabuの平凡な日常を淡々と描く物です。 過度な期待はしないでください。 あと、部屋は明るくして、 モニターから3メートルは離れて見やがってください。

Installed Vim7.4

Ruby CentOS Vim Python Perl

更新履歴 Update history

  • 2013/09/02:
    • anyenv対応(Perl、Python3オプション追加)

背景 Background

Rubyの開発でVimを利用する予定だったのですが、
既存のVimのバージョンが古く最近のプラグインが利用できなかったため、
最新のVimをインストールする事にしました。

目標 Goal

  • 最新のVimである事
  • Rubyがサポートされている事
  • NeoCompleteプラグインが利用できる事

環境 Environment

既存のVim Old version Vim

整形しようとして、3行目くらいで挫折しました。

$ vim --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Apr  5 2012 10:17:30)
適用済パッチ: 1-411
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
Huge 版 without GUI.  機能の一覧 有効(+)/無効(-)
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+cryptv +cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic
+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path
+float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand
+jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap
+menu +mksession +modify_fname +mouse -mouseshape +mouse_dec +mouse_gpm
-mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte
+multi_lang -mzscheme -netbeans_intg -osfiletype +path_extra +perl +postscript
+printer +profile +python +quickfix +reltime +rightleft -ruby +scrollbind
+signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax
+tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse
+textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual
+visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup
-X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save

初期設定

本処理はsudo権限で行いますが、env系まわりでmabuアカウントのPATHをsudoにも引き継ぐ必要があります。

$ alias sudo='sudo env PATH=$PATH'

事前準備

オプションが増えてきたので、詳細は割愛

$ sudo which ruby
/home/mabulog/.anyenv/envs/rbenv/shims/ruby
$ sudo which python
/home/mabulog/.anyenv/envs/pyenv/shims/python
$ find .anyenv/envs/pyenv -name "config.c"
.anyenv/envs/pyenv/versions/3.3.2/lib/python3.3/config-3.3m/config.c
$ sudo which perl
/home/mabulog/.anyenv/envs/plenv/shims/perl
$ sudo find / -name "lua.h"
/usr/local/include/luajit-2.0/lua.h

その結果

--enable-rubyinterp \
--with-ruby-command=/home/mabulog/.anyenv/envs/rbenv/shims/ruby \
--enable-python3interp \
--with-python3-config-dir=/home/mabulog/.anyenv/envs/pyenv/versions/3.3.2/lib/python3.3/config-3.3m \
--enable-perlinterp \
--enable-luainterp \
--with-lua-prefix=/usr/local \
--with-luajit

手順 Operation

$ sudo yum remove vim-enhanced vim-common
$ hg clone https://vim.googlecode.com/hg/ /usr/local/src/vim
$ cd /usr/local/src/vim
$ sudo ./configure \
    --prefix=/usr/local \
    --enable-fail-if-missing \
    --disable-darwin \
    --disable-selinux \
    --disable-xsmp \
    --disable-xsmp-interact \
    --enable-cscope \
    --disable-netbeans \
    --enable-multibyte \
    --disable-xim \
    --enable-fontset \
    --with-features=huge \
    --enable-rubyinterp \
    --with-ruby-command=/home/mabulog/.anyenv/envs/rbenv/shims/ruby \
    --enable-python3interp \
    --with-python3-config-dir=/home/mabulog/.anyenv/envs/pyenv/versions/3.3.2/lib/python3.3/config-3.3m \
    --enable-perlinterp \
    --enable-luainterp \
    --with-lua-prefix=/usr/local \
    --with-luajit
$ sudo make && sudo make install

インストール後のVim New version Vim

$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep  2 2013 20:16:22)
適用済パッチ: 1-16
Compiled by mabulog@localhost.localdomain
Huge 版 without GUI.  機能の一覧 有効(+)/無効(-)
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    -netbeans_intg   +title
-clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       -python          +viminfo
+cscope          +lispindent      +python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      +lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
      システム vimrc: "$VIM/vimrc"
        ユーザ vimrc: "$HOME/.vimrc"
     第2ユーザ vimrc: "~/.vim/vimrc"
         ユーザ exrc: "$HOME/.exrc"
       省略時の $VIM: "/usr/local/share/vim"
コンパイル: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
リンク: gcc   -L. -L/home/mabulog/.anyenv/envs/rbenv/versions/2.0.0-p247/lib  -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E   -L/usr/local/lib -Wl,--as-needed -o vim        -lm -ltinfo -lelf   -ldl  -L/usr/local/lib -lluajit-5.1 -Wl,-E  -fstack-protector -L/usr/local/lib  -L/home/mabulog/.anyenv/envs/plenv/versions/5.19.3/lib/perl5/5.19.3/x86_64-linux/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lc  -L/home/mabulog/.anyenv/envs/pyenv/versions/3.3.2/lib/python3.3/config-3.3m -lpython3.3m -lpthread -ldl -lutil -lm  -Wl,-R -Wl,/home/mabulog/.anyenv/envs/rbenv/versions/2.0.0-p247/lib -L/home/mabulog/.anyenv/envs/rbenv/versions/2.0.0-p247/lib -lruby-static -lpthread -lrt -ldl -lcrypt -lm  -L/home/mabulog/.anyenv/envs/rbenv/versions/2.0.0-p247/lib

最新のVim取得 New Vim version get

$ cd /usr/local/src/vim
$ sudo hg pull

Vimアンインストール

$ cd /usr/local/src/vim
$ sudo make uninstall
$ sudo make clean

エラー Error

Ruby配置場所不明エラー

$ sudo ./configure \
....
checking --enable-rubyinterp argument... yes
checking --with-ruby-command argument... defaulting to ruby
checking for ruby... no
configure: error: could not configure Ruby

sudoではrubyのパスがわからない事が原因のため、
明示的にrubyの場所指定。

--with-ruby-command=/home/mabulog/.rbenv/shims/ruby

LuaJITの設置場所不明エラー1

$ sudo ./configure \
....
checking --enable-luainterp argument... yes
checking --with-lua-prefix argument... no
checking LUA_PREFIX environment var... not set, default to /usr
checking --with-luajit... yes
checking for luajit... no
checking if lua.h can be found in /usr/include... no
checking if lua.h can be found in /usr/include/lua5.1... no
configure: error: could not configure lua

LuaJITがライブラリ参照域に設置されていないため、
シンボリックリンクで対応

$ sudo ln -s  /usr/local/bin/luajit /usr/bin/luajit

LuaJITの設置場所不明エラー2

$ sudo ./configure \
....
checking --enable-luainterp argument... yes
checking --with-lua-prefix argument... no
checking LUA_PREFIX environment var... not set, default to /usr
checking --with-luajit... yes
checking for luajit... /usr/bin/luajit
checking LuaJIT version... 2.0
checking Lua version of LuaJIT... 5.1
checking if lua.h can be found in /usr/include/luajit-2.0... checking if lua.h can be found in /usr/include... no
checking if lua.h can be found in /usr/include/lua5.1... no
configure: error: could not configure lua

LuaJITの"lua.h "設置位置が不明なため、
明示的に指定する。

--with-lua-prefix=/usr/local

libluajit-5.1.soの設置場所不明エラー3

$ vim --version
vim: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory

LD_LIBRARY_PATHを".bash_profile"に追記しました。

$ vi .bash_profile
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH

$ source .bash_profile
$ env |grep LD_LIBRARY_PATH
LD_LIBRARY_PATH=..../usr/local/lib

メモ Memo

$ sudo ./configure --help
`configure' configures this package to adapt to many kinds of systems.

Usage: auto/configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

X features:
  --x-includes=DIR    X include files are in DIR
  --x-libraries=DIR   X library files are in DIR

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-fail-if-missing    Fail if dependencies on additional features
     specified on the command line are missing.
  --disable-darwin        Disable Darwin (Mac OS X) support.
  --disable-selinux   Don't check for SELinux support.
  --disable-xsmp          Disable XSMP session management
  --disable-xsmp-interact Disable XSMP interaction
  --enable-luainterp=OPTS     Include Lua interpreter.  default=no OPTS=no/yes/dynamic
  --enable-mzschemeinterp   Include MzScheme interpreter.
  --enable-perlinterp=OPTS     Include Perl interpreter.  default=no OPTS=no/yes/dynamic
  --enable-pythoninterp=OPTS   Include Python interpreter. default=no OPTS=no/yes/dynamic
  --enable-python3interp=OPTS   Include Python3 interpreter. default=no OPTS=no/yes/dynamic
  --enable-tclinterp      Include Tcl interpreter.
  --enable-rubyinterp=OPTS     Include Ruby interpreter.  default=no OPTS=no/yes/dynamic
  --enable-cscope         Include cscope interface.
  --enable-workshop       Include Sun Visual Workshop support.
  --disable-netbeans      Disable NetBeans integration support.
  --enable-sniff          Include Sniff interface.
  --enable-multibyte      Include multibyte editing support.
  --enable-hangulinput    Include Hangul input support.
  --enable-xim            Include XIM input support.
  --enable-fontset        Include X fontset output support.
  --enable-gui=OPTS     X11 GUI default=auto OPTS=auto/no/gtk2/gnome2/motif/athena/neXtaw/photon/carbon
  --enable-gtk2-check     If auto-select GUI, check for GTK+ 2 default=yes
  --enable-gnome-check    If GTK GUI, check for GNOME default=no
  --enable-motif-check    If auto-select GUI, check for Motif default=yes
  --enable-athena-check   If auto-select GUI, check for Athena default=yes
  --enable-nextaw-check   If auto-select GUI, check for neXtaw default=yes
  --enable-carbon-check   If auto-select GUI, check for Carbon default=yes
  --disable-gtktest       Do not try to compile and run a test GTK program
  --disable-largefile     omit support for large files
  --disable-acl           Don't check for ACL support.
  --disable-gpm           Don't use gpm (Linux mouse daemon).
  --disable-sysmouse    Don't use sysmouse (mouse in *BSD console).
  --disable-nls           Don't support NLS (gettext()).

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-mac-arch=ARCH    current, intel, ppc or both
  --with-developer-dir=PATH    use PATH as location for Xcode developer tools
  --with-local-dir=PATH   search PATH instead of /usr/local for local libraries.
  --without-local-dir     do not search /usr/local for local libraries.
  --with-vim-name=NAME    what to call the Vim executable
  --with-ex-name=NAME     what to call the Ex executable
  --with-view-name=NAME   what to call the View executable
  --with-global-runtime=DIR    global runtime directory in 'runtimepath'
  --with-modified-by=NAME       name of who modified a release version
  --with-features=TYPE    tiny, small, normal, big or huge (default: normal)
  --with-compiledby=NAME  name to show in :version message
  --with-lua-prefix=PFX   Prefix where Lua is installed.
  --with-luajit           Link with LuaJIT instead of Lua.
  --with-plthome=PLTHOME   Use PLTHOME.
  --with-python-config-dir=PATH  Python's config directory
  --with-python3-config-dir=PATH  Python's config directory
  --with-tclsh=PATH       which tclsh to use (default: tclsh8.0)
  --with-ruby-command=RUBY  name of the Ruby command (default: ruby)
  --with-x                use the X Window System
  --with-gnome-includes=DIR Specify location of GNOME headers
  --with-gnome-libs=DIR   Specify location of GNOME libs
  --with-gnome            Specify prefix for GNOME files
  --with-motif-lib=STRING   Library for Motif
  --with-tlib=library     terminal library to be used

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  XMKMF       Path to xmkmf, Makefile generator for X Window System

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to the package provider.

今後 To be continue.

NeoBundleプラグインの導入記事を書く予定です。
この記事に追加するか、別途記事をおこすかは検討中です。

NeoCompleteプラグインも含めプラグインの理解を深めた方が良さそうです。
Vimの環境が出来上がった場合にはRubyの勉強を本格的に始めたいと思います。
どうしても手詰まりになったらPerl with plenv、Python with pyenv環境構築の記事を書いて、vimPerlPythonサポートさせます。

Python3とPerlはサポートしました。(2013/09/03)

参考サイト Reference