Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with Vim's Ruby plugin

Tags:

vim

plugins

ruby

I have just installed Vim and when ever I go to open in ruby file I get these errors:

Error detected while processing C:\Program files (x86)\Vim\vimfiles\ftplugin\ruby.vim
line: 76
Encoding::ConverterNotFoundError: code converter not found (UTF-16LE to ASCII-8bit)
line: 93

E121 :Undefined varaible: s:ruby_path
E15: Invalid expression: s:ruby_path
line: 76

NameError: uninitialized constant Gem::Quickloader
line: 93

I have Ruby 192 installed and I get this error even if I update ruby vim files.

These are the two lines those errors are referring to if it helps:

line 76:  ruby VIM::command( 'let s:ruby_path = "%s"' % ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,}) )

line 93: let &l:path = s:ruby_path
like image 972
Alex Avatar asked Nov 27 '10 21:11

Alex


2 Answers

Note that instead of editing ruby.vim file you can just add

let g:ruby_path = ':C:\ruby192\bin'

in your _vimrc file (or equivalent for your platform). That way you won't need to keep re-editing ruby.vim when you update it.

like image 100
mr_stru Avatar answered Oct 08 '22 18:10

mr_stru


If you run RVM and want its default ruby, use:

let g:ruby_path = "/Users/allen/.rvm/rubies/default/bin"

If you set your ruby interpreter in your project .rvmrc file, you can create an environment variable in your .rvmrc:

rvm 1.9.2@projectname --create
export RUBY_BIN=`which ruby | sed 's/ruby$//'`

You can use environment variables in your .vimrc:

let g:ruby_path=$RUBY_BIN

(Note you should also set a default $RUBY_BIN in your .bashrc or .zshrc so this works outside of .rvmrc projects.)

If your ~/.rvm/rubies/default/bin path does not yet exist, you need to set your rvm system default of ruby. At your command prompt or terminal application, enter:

rvm use 1.9.2 --default

using whatever ruby version you need.

like image 5
Allen Avatar answered Oct 08 '22 19:10

Allen