Problem with Vim's Ruby plugin

后端 未结 6 1092
一整个雨季
一整个雨季 2021-02-13 18:34

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\\ftp         


        
相关标签:
6条回答
  • 2021-02-13 19:06

    How did you install Ruby?

    Go into irb and enter:

    Gem.all_load_paths.uniq
    

    which should return a list of paths to your install gems that Gem knows about also.

    That's what is failing in your error message and leads me to suspect you are missing some path or environment info, because it looks like vim isn't able to find your Ruby gems correctly.

    Encoding::ConverterNotFoundError is a core library exception, so that part is working, but it looks like the Gem command isn't working.

    0 讨论(0)
  • 2021-02-13 19:10

    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.

    0 讨论(0)
  • 2021-02-13 19:11

    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.

    0 讨论(0)
  • 2021-02-13 19:15

    Your problem is probably Ruby 1.9 - AFAIK Vim only works with Ruby 1.8, so you might have to downgrade your Ruby version to get Vim working.

    0 讨论(0)
  • 2021-02-13 19:18

    I opened the file "C:...\vim73\ftplugin\ruby.vim" and right before line 73 or so, where the code reads:

    if !exists("s:ruby_path")
    

    I added:

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

    So far vim seems happier about editing ruby files. Note I installed my ruby in the "C:" directory instead of "Program Files" to get a better pathname to ruby.exe.

    My version of ruby.vim is dated 2010 Mar 15.

    0 讨论(0)
  • 2021-02-13 19:22

    Updating to the latest release of Ruby 1.9.2 (1.9.2p180 (2011-02-18) at the time of posting) fixed this for me.

    I was running 1.9.2p132 or so when I had the problem, which seems to have been patched around Dec 2010. You can check your current version by running ruby -v.

    0 讨论(0)
提交回复
热议问题