Vim で Rails の Omni 補完をするとバッファが乱れる
rails で omni 補完すると、こんな感じになってバッファが変になって戻らないんだけどなんでだろ。
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
これの3行目をコメントアウトすると、変にならない。
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
これの3行目をコメントアウトすると、変にならない。
で、サンプルで以下のようにプロジェクトを作成したら、途中でエラーが発生した。–trace オプションで詳細情報を出力。
% rails new test-prj
% test-prj/
% rails generate scaffold tbl value:string
invoke active_record
…
% rake db:migrate
== CreateTbls: migrating =====================================================
-- create_table(:tbls)
-> 0.0011s
== CreateTbls: migrated (0.0012s) ============================================
% rake routes --trace
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/execjs-1.3.0/lib/execjs.rb:5:in `'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/execjs-1.3.0/lib/execjs.rb:4:in `'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.2/lib/bundler/runtime.rb:68:in `require'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.2/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.2/lib/bundler/runtime.rb:66:in `each'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.2/lib/bundler/runtime.rb:66:in `block in require'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.2/lib/bundler/runtime.rb:55:in `each'
/home/suVene/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.2/lib/bundler/runtime.rb:55:in `require'
sstephenson/execjs · GitHub や “Could not find a JavaScript runtime” と Rails 3.1 起動に失敗する件 | MOYO Laboratory や他のサイトを検索すると、Rails 3.1 から CoffeScript のために、JavaScript Runtime が必要になったとのこと。
なので、
% gem install therubyracer
してみたのだが解消せず。
するとなぜだか、Node.js をインストールすればよいという情報があったので、そのとおりにしたら解消した。
% wget http://nodejs.org/dist/node-v0.6.9.tar.gz
% tar zxfv node … 以下略
いじょ、終わり。
$ gem install rubygems-update
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
(もちろん zlib, zlib-devel はインストール済みで install 時にも –with-zlib-dir を渡してる)
このパターンのトラブルシューティングは、以下のようにして回避ってのが定番なんだが、どうもうまくいかない。
$ $rvm_path/src/ruby-1.9.3-p125/ext/zlib
$ ruby extconf.rb
$ ../../
$ make
$ make install
でも、エラーでまくり。
checking for deflateReset() in -ltrue... no
checking for deflateReset() in -llibz... no
checking for deflateReset() in -lzlib1... no
checking for deflateReset() in -lzlib... no
checking for deflateReset() in -lzdll... no
散々調べまっくた経緯を4000字ほど書きたいところだが、結論だけ書くと、公式にあるようにすれば一発で OK だった。
Remove all the manually installed packages:
$ rm -rf $rvm_path/usrFind the requirements (follow the instructions):
$ rvm requirementsReinstall ruby:
$ rvm reinstall 1.9.3
ちなみに、readline やら、openssl でエラーが出ても、手順は似たようなものになると思う。
あと、rvm pkg install readline のときに、autoreconf でエラーが出てたんだが、これも公式にあったように、
$ rvm --skip-autoreconf pkg install readline
とすれば、インストールできた。(いいのか??)
まぁ、とりあえずは動きそうだからよいか。
しかし、なんで –with-zlib-dir… を指定して、reinstall してもエラーなのに、何の指定もなしでエラーが無くなったんだろう。余分だったのかな。
ライブラリはこれだけインストールしときゃ、だいたい幸せなはず。
sudo yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel
Git のバージョンは、1.6.2 以上。perl, OpenSSH は準備できているものとする。
作業用端末で新しい認証鍵(公開鍵・秘密鍵のペア)を作成する。
$ ssh-keygen -t rsa
$ Generating public/private rsa key pair.
Enter file in which to save the key (/User/suVene/.ssh/id_rsa): /User/suVene/.ssh/suVene
注意事項として、普段 ssh でログインとは別に作成しておく必要がある。gitlite のインストールに設定する認証鍵でターミナルでログインすると、git 管理用に操作が制限されてしまうので、レンタルサーバなどだとログイン不可能になってしまう。
普段通りに作業用端末からログインし、管理用ユーザを作成する。
/tmp/id_rsa.pub は、ログインユーザ(作業用端末)の公開鍵。
$ sudo adduser gitolite --shell /bin/bash --home-dir /home/gitolite -c 'gitloite'
$ sudo passwd gitolite
$ sudo su - gitlite
$ cd
$ mkdir -p .ssh -m 0700
$ cp /tmp/id_rsa.pub .ssh/authorized_keys
$ chmod 0600 .ssh/authrized_keys
$ exit
まず、パスが上手くとおらないことがあるので、以下を .bashrc に記述しておく。
export PATH="$HOME/bin:$HOME/gitolite/bin:/usr/local/bin:/usr/bin:/bin"
gitolite をクローンして、スクリプト叩くだけ。
suVene.pub は、「準備」で作成した、新しい公開鍵。
$ ssh gitolite@vps.example.com
$ git clone git://github.com/sitaramc/gitolite
$ gitolite/src/gl-system-install -q
Usage:
gl-system-install [bin-dir conf-dir hooks-dir]
Requires all 3 arguments or none. All arguments supplied must be absolute
paths. The following defaults are used if arguments are not supplied:
as normal user: $HOME/bin, $HOME/share/gitolite/conf, $HOME/share/gitolite/hooks
as root: /usr/local/bin, /var/gitolite/conf, /var/gitolite/hooks
$ gitolite/src/gl-system-install $HOME/bin $HOME/share/gitolite/conf $HOME/share/gitolite/hooks
$ gl-setup -h
Usage:
gl-setup [-q] [-q] [YourName.pub] # ssh mode
gl-setup [-q] [-q] [YourName] # http mode
Please see 'appendix d' in doc/install.mkd for more. (Online at
http://sitaramc.github.com/gitolite/install.html#gl-setup)
$ gl-setup -q suVene.pub
creating gitolite-admin...
Initialized empty Git repository in /home/gitolite/repositories/gitolite-admin.git/
creating testing...
Initialized empty Git repository in /home/gitolite/repositories/testing.git/
[master (root-commit) 8fe8e24] gl-setup -q suVene.pub
2 files changed, 8 insertions(+), 0 deletions(-)
create mode 100644 conf/gitolite.conf
create mode 100644 keydir/suVene.pub
これでインストール完了。
作業用端末の ~/.ssh/config に以下の設定を追記。
Host gitolite
User gitolite
Hostname vps.example.com
IdentityFile /Users/suVene/.ssh/{新しい秘密鍵}
git clone gitolite:gitolite-admin
あとは、このリポジトリに対してユーザの追加や読み書き設定を commit して push すればよい。かなり細かい制御ができるのだが、それは、「参考 URL」などを参考に。
以上、おわり。
これは、vandle の説明だが、基本は同じ。
Vundleは、Rails 3 でも採用されている依存性を解決するためのライブラリであるBundlerにインスパイアされたVimプラグインマネージャです。
Vundleを使えば、あなたのVimプラグイン生活が一新します。
- .vimrcの中でプラグインを一元管理できます
- Vim上でプラグインの検索ができます
- Vim上で再起動することなくプラグインのインストール、アップデートができます
それプラス、
- コマンド名が改善されている
- shellslashがオンでも動作する
- vimprocに対応している
- unite.vimインタフェースの実装
- Subversion, Mercurialへの対応
- リビジョン指定
手順は How do I remove a git submodule? – Stack Overfdilow にあるとおり。
To remove a submodule you need to:
- Delete the relevant line from the
.gitmodulesfile.- Delete the relevant section from
.git/config.- Run
git rm --cached path_to_submodule(no trailing slash).- Commit and delete the now untracked submodule files.
なにこれ、めんどくさい。
(これ 使えば良いっぽいけど、数が少ないから手で消した)
git submodule add https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim
README にあるとおりだけど。
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim/
call neobundle#rc(expand('~/.vim/bundle'))
endif
" let NeoBundle manage NeoBundle
" required!
NeoBundle 'Shougo/neobundle.vim'
" recommended to install
NeoBundle 'Shougo/vimproc'
" after install, turn shell ~/.vim/bundle/vimproc, (n,g)make -f your_machines_makefile
NeoBundle 'Shougo/vimshell'
NeoBundle 'Shougo/unite.vim'
"" My Bundles here:
"
"" original repos on github
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'Lokaltog/vim-easymotion'
NeoBundle 'rstacruz/sparkup', {'rtp': 'vim/'}
NeoBundle 'tpope/vim-rails.git'
NeoBundle 'fholgado/minibufexpl.vim'
NeoBundle 'Shougo/neocomplcache'
NeoBundle 'othree/eregex.vim'
NeoBundle 'ornicar/vim-mru'
NeoBundle 'mattn/zencoding-vim'
NeoBundle 'kana/vim-surround'
NeoBundle 'gmarik/vundle'
" BundleSearch 用に
set runtimepath+=~/.vim/bundle/vundle.git/
call vundle#rc()
"" vim-scripts repos
NeoBundle 'L9'
NeoBundle 'FuzzyFinder'
NeoBundle 'ruby.vim'
"" non github repos
NeoBundle 'git://git.wincent.com/command-t.git'
"" non git repos
NeoBundle 'http://svn.macports.org/repository/macports/contrib/mpvim/'
NeoBundle 'https://bitbucket.org/ns9tks/vim-fuzzyfinder'
filetype plugin indent on " required!
vim を起動して
:NeoBundleInstall
vimproc は make して .so を作る必要がある。
$ cd ~/.vim/bundle/vimproc $ make -f make_mac.mak # 環境により異なる $ ln -s $HOME/.vim/bundle/vimproc/autoload/proc.so $HOME/.vim/autoload
Recent Comments