rufo-vim icon indicating copy to clipboard operation
rufo-vim copied to clipboard

rufo fails to run after triggering rails omnicompletion

Open ralfthewise opened this issue 6 years ago • 1 comments

Repro:

[tim@hood]$ cat <<EOF > /tmp/vimrc
set nocompatible
call plug#begin()
Plug 'ruby-formatter/rufo-vim'
call plug#end()
syntax on
filetype on
filetype indent on
filetype plugin on
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
EOF

[tim@hood]$ vim -u /tmp/vimrc config/initializers/kaminari_config.rb

# trigger omnicompletion somewhere by entering edit mode and hitting CTRL-x CTRL-o
# then try issuing the :Rufo command - you'll see this error output:
/usr/local/rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/rubygems_integration.rb:458:in `block in replace_bin_path': can't find executable rufo for gem rufo. rufo is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
        from /usr/local/rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/rubygems_integration.rb:478:in `block in replace_bin_path'
        from /usr/local/rvm/gems/ruby-2.5.1/bin/rufo:27:in `<main>'
        from /usr/local/rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `eval'
        from /usr/local/rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `<main>'

I have rufo installed globally, not in the bundle. I use junegunn/vim-plug for vim plugin management, but I'm guessing that has no bearing on this issue. Prior to triggering omnicompletion rufo runs fine.

ralfthewise avatar Jun 26 '18 22:06 ralfthewise

Looks like this is caused by omnicompletion loading the bundle which then breaks rufo. These environment variables seem to be the main culprits: GEM_HOME GEM_PATH and RUBYOPT. Doing something like:

let l:out = systemlist('echo ' . shellescape(l:selection) . '| ruby -e "defined?(Bundler) ? Bundler.with_clean_env { system(%(rufo)) } : system(%(rufo))"')

may work, but wondering if that would break things for someone who only has rufo installed as part of a bundle. Will have to do some testing and hopefully submit a PR in the next couple days.

ralfthewise avatar Jun 26 '18 23:06 ralfthewise