ruby.vim does not work with greater than rubygems 1.7

139 views
Skip to first unread message

mattn

unread,
Jul 21, 2011, 7:37:45 AM7/21/11
to vim...@googlegroups.com
Hi list.

I updated rubygems, then I got an error while opening *.rb file always.
It seems some method become deprecated.

Below is a patch that use fallback using Gem::Specification.

Please check and include.

This patch change expression of &shellxquote == "'" to &shellxquote != '"'.
shellxquote can set empty value on windows. It have better to use &shellxquote != '"'.

Thanks.
- Yasuhiro Matsumoto

diff -r 1d1065c2e7fa runtime/ftplugin/ruby.vim
--- a/runtime/ftplugin/ruby.vim Wed Jul 20 18:29:39 2011 +0200
+++ b/runtime/ftplugin/ruby.vim Thu Jul 21 20:34:19 2011 +0900
@@ -73,11 +73,11 @@
   if exists("g:ruby_path")
     let s:ruby_path = g:ruby_path
   elseif has("ruby") && has("win32")
-    ruby VIM::command( 'let s:ruby_path = "%s"' % ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,}) )
+    ruby VIM::command( 'let s:ruby_path = "%s"' % ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue NoMethodError; Gem::Specification.map{|s|s.gem_dir}.sort.uniq; rescue LoadError; []; end).join(%q{,}) )
     let s:ruby_path = '.,' . substitute(s:ruby_path, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
   elseif executable("ruby")
-    let s:code = "print ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,})"
-    if &shellxquote == "'"
+    let s:code = "print ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue NoMethodError; Gem::Specification.map{|s|s.gem_dir}.sort.uniq; rescue LoadError; []; end).join(%q{,})"
+    if &shellxquote != '"'
       let s:ruby_path = system('ruby -e "' . s:code . '"')
     else
       let s:ruby_path = system("ruby -e '" . s:code . "'")

mattn

unread,
Jul 21, 2011, 7:47:06 AM7/21/11
to vim...@googlegroups.com
Ah, sorry.

"Gem.all_load_paths.sort.uniq" have better to be fallback. it show warning message.
Check following.

diff -r 1d1065c2e7fa runtime/ftplugin/ruby.vim
--- a/runtime/ftplugin/ruby.vim Wed Jul 20 18:29:39 2011 +0200
+++ b/runtime/ftplugin/ruby.vim Thu Jul 21 20:43:42 2011 +0900
@@ -73,11 +73,11 @@
   if exists("g:ruby_path")
     let s:ruby_path = g:ruby_path
   elseif has("ruby") && has("win32")
-    ruby VIM::command( 'let s:ruby_path = "%s"' % ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,}) )
+    ruby VIM::command( 'let s:ruby_path = "%s"' % ($: + begin; require %q{rubygems}; Gem::Specification.map{|s|s.gem_dir}.sort.uniq; rescue NoMethodError; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,}) )
     let s:ruby_path = '.,' . substitute(s:ruby_path, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
   elseif executable("ruby")
-    let s:code = "print ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,})"
-    if &shellxquote == "'"
+    let s:code = "print ($: + begin; require %q{rubygems}; Gem::Specification.map{|s|s.gem_dir}.sort.uniq; rescue NoMethodError; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,})"

Bram Moolenaar

unread,
Jul 21, 2011, 4:29:24 PM7/21/11
to mattn, vim...@googlegroups.com, Gavin Sinclair

Mattn wrote:

> I updated rubygems, then I got an error while opening *.rb file always.
> It seems some method become deprecated.
>
> Below is a patch that use fallback using Gem::Specification.
>
> Please check and include.
>
> This patch change expression of &shellxquote == "'" to &shellxquote != '"'.
> shellxquote can set empty value on windows. It have better to
> use &shellxquote != '"'.

And a copy to the maintainer.

--
** Hello and Welcome to the Psychiatric Hotline **
If you are obsessive-compulsive, please press 1 repeatedly.
If you are co-dependent, please ask someone to press 2.
If you have multiple personalities, please press 3, 4, 5 and 6.
If you are paranoid-delusional, we know who you are and what you want
- just stay on the line so we can trace the call.
If you are schizophrenic, listen carefully and a little voice will
tell you which number to press next.
If you are manic-depressive, it doesn't matter which number you press
- no one will answer.
If you suffer from panic attacks, push every button you can find.
If you are sane, please hold on - we have the rest of humanity on the
other line and they desparately want to ask you a few questions.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Message has been deleted

mattn

unread,
Jan 31, 2012, 9:01:17 PM1/31/12
to vim...@googlegroups.com, mattn, Gavin Sinclair
Sorry, mistaken to reply.

It seems that some users hope fixing this issue.
This warning appear in ruby 1.9 later.

Reply all
Reply to author
Forward
0 new messages