Open powersurge360 opened 2 years ago
It looks like the invocation that corrects it is return 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), trim_mode: %{-}).src') . '< %t | ruby -c'
but I don't have a good grasp of what it's doing so I'm not sure. At least, it doesn't seem to have any deprecation warnings.
I'm pretty green on VimScript, but if someone can point me towards where a solve like this has been implemented in the past, I can take a crack at fixing this myself. I imagine there's probably a utility written somewhere in the codebase that makes these version checks generic based on the executable.
You can check ansible_lint.vim and vint.vim for examples on how to generate the command depending on the tool version.
Workaround is to define your own function like
https://github.com/dense-analysis/ale/blob/master/ale_linters/eruby/erb.vim
It has to be in file with the path as the function name.
So create a file inside this folder mkdir -p ~/.vim/ale_linters/eruby
" ~/.vim/ale_linters/eruby/erb.vim
function! ale_linters#eruby#erb#GetCommand(buffer) abort
return 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c'
endfunction
and include it in your .vimrc
" .vimrc
" overwrite default ERB linter untill this is fixed
" https://github.com/dense-analysis/ale/issues/4167
source ~/.vim/ale_linters/eruby/erb.vim
Information
VIM version
NVIM v0.7.0
Build type: Release
Operating System: macOS 12.3.1
What went wrong
Ruby 3.1.2 (and maybe all Ruby 3.x versions) have a deprecation message when using the eruby ALE linter in rails applications.
Specifically, the error message you get is:
Passing trim_mode with the 3rd argument of erb.new is deprecated
.This error message seems to come from ale itself and can be fixed by perhaps splitting based on ruby versions to use the older signature in older rubies and the newer signature in newer rubies.
Reproducing the bug
Passing trim_mode with the 3rd argument of erb.new is deprecated
:ALEInfo
I think the problem is in this line
(finished - exit code 0) ['/bin/zsh', '-c', 'ruby -r erb -e ''puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src''< ''/var/folders/6v/d3rhg9yd7vq4dpx9fbj2v9hh0000gn/T/nvimtnUgQQ/30/new.html.erb'' | ruby -c']
. The deprecation messages are also visible in the log.