-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rg 13.0.0 breaks integration with NeoVim #1892
Comments
I'm not keen on adding flags to change stdin detection unless there is absolutely no other way. I suppose the obvious question here is this: why is ripgrep being started with a socket attached to stdin that shouldn't be searched? I tried to answer this question myself by looking at the plugin's source, but couldn't really make sense of it. |
I believe that is how background job processing is implemented in NeoVim. NeoVim uses libuv with the event loop processing, which AFAIK is socket based. |
Thanks for responding, but it doesn't really help my understanding here. Why is it attaching a socket to stdin in the first place? I understand this is probably frustrating since ripgrep changed its behavior and caused a breakage here, but before I'm willing to implement a kludge or break somebody's else's patch, I need to understand whether the plugin itself is working correctly or not. It eould be very surprising to me if "attach a socket to stdin" was an unavoidable consequence of libuv, for example. Either something about my mental model is off, or something isn't quite right on the plugin side of things. |
And note that a work around is very simple here. No flag is needed. Just pass |
I've just checked and the plugin is working fine with the regular Vim. It must be something related to the way NeoVim implements the communication with the external processes. So I assumed that it is related to libuv, but I'm not 100% sure about it. Passing |
That's quite interesting because that should disable stdin detection. Hmmm. |
Maybe i'm using it incorrectly. Is this a correct way to run it?:
|
Yes. That should not try to "detect" whether stdin is readable or not. But maybe my understanding is wrong. I'll check the code again once I'm back on a keyboard. |
diff --git a/plugin/grepper.vim b/plugin/grepper.vim
index 73e4e36..40c455f 100644
--- a/plugin/grepper.vim
+++ b/plugin/grepper.vim
@@ -935,6 +935,7 @@ function! s:run(flags)
\ 'on_stdout': function('s:on_stdout_nvim'),
\ 'on_stderr': function('s:on_stdout_nvim'),
\ 'on_exit': function('s:on_exit'),
+ \ 'pty': 1
\ }
if !a:flags.stop
let opts.stdout_buffered = 1 should work. |
Note that this also affects other (Neovim) plugins, which used the workaround to append ".": nvim-telescope/telescope.nvim#908
Any specific reason to use |
Thanks. That fixes the issue. It seems to work fine with other tools like |
OK, doing a bit of a code walkthrough here, this is the implementation of Lines 183 to 213 in 7ce66f7
On Unix, this is getting a handle to stdin's file descriptor, So where is this used? It's used inside of ripgrep when determining which thing to search when it is otherwise not given at least one thing to search as a positional parameter: Lines 1325 to 1342 in 7ce66f7
Whether The part where I'm getting hung up is that the Lines 554 to 559 in 7ce66f7
So, if you provide |
v13.0.0 broke a number of tools in Neovim, but not in Vim, as described here: BurntSushi/ripgrep#1892 My reading of that is that changes to Neovim will/may be required, because the `rg` author is right that rg's handling is "technically correct" and I don't think he's going to change it. Luckily, we don't have to take sides in that argument because there is a straightforward enough workaround of always providing a path to search (ie. ".", only if one isn't already provided by the user). <tangential-rant> As I lamented here: https://twitter.com/wincent/status/1413536091425198082 installing and building docvim on this machine (in order to include the update to the "HISTORY" section in the docs) is a frickin' ordeal. It takes: 1. 5.53s to clone the repo. 2. 3m56s to install GHC. 3. 3m24s to build the project. 4. 1.64s to run the built tool. Which seems massively out-of-proportion for something that clocks in at 1,380 lines of Haskell according to `sloccount`. On the upside, this is one of the few tasks I can throw at this Linux box that actually taxes the machine. 😆 Steps: git clone git@git.wincent.com:public/docvim.git cd docvim bin/docvim \ -c ~/.vim/pack/bundle/opt/ferret \ ~/.vim/pack/bundle/opt/ferret/README.md \ ~/.vim/pack/bundle/opt/ferret/doc/ferret.txt # That did't work; need to build first, then retry: bin/build bin/docvim \ -c ~/.vim/pack/bundle/opt/ferret \ ~/.vim/pack/bundle/opt/ferret/README.md \ ~/.vim/pack/bundle/opt/ferret/doc/ferret.txt Closes: #78
A clarification: folks seem to think that I am holding a line here because I'm insisting on being "technically correct" here. That's not why I'm doing what I'm doing here. The patch that broke neovim plugin integration was fixing another bug. Perhaps a less prominent one, but not insignificant. So the choice here isn't between "being pragmatic" and "being technically correct." The choice here is, "who do we break?" (As far as I can tell anyway.) |
@BurntSushi |
I'm not keen on adding flags for this. Especially since it looks like a temporary problem. @blueyed Does the |
Crazy untested idea: is it possible to connect stdin to |
@BurntSushi The pty-trick needs to be extended (mhinz/vim-grepper#244 (comment)), but might be what ends in vim-grepper if there is nothing better, like a fix/explicit flag in ripgrep. |
Why this issue is closed? does this bug have been fixed. I still can reproduce it in my plugin. SpaceVim/SpaceVim#4329 neovim version is: v0.5.0 release |
The answer to your question is in the comments above. The problem isn't in ripgrep. Neovim is attaching a readable stdin file descriptor to every subprocess executed. There's even a PR against neovim to fix it. Work arounds have been documented above. |
hmm. I do not know. But why old old version of rg works well for me. I need to lock my rg version to 0.10.0 |
It's explained above. See the link to the commit that introduced this change for example. You don't need to use an old version of ripgrep. Certainly not one that is many years old. Just use Again, please read the comments above. It should all be explained. If you have specific questions to things said, feel free to ask. |
To close the loop here (and for those still following this issue), neovim/neovim#14812 landed in Neovim and provides a way for Note that the Neovim fix hasn't been pushed in an official release yet (that is 0.5 doesn't have it) and thus it requires using the nightly 0.6 Neovim build. Thanks for your help investigating this @BurntSushi! |
@ddeville thanks, I am using 0.5.0 now. |
For anyone comming here using vim-grepper, I have a suggestion to help you guys use it and also apply the workaround suggested by this comment: #1892 (comment) I have a custom function that gets called by some keymappings that I ported from this plugin a while ago: https://github.com/vim-scripts/grep.vim . The function is: function! s:my_run_grep()
let l:pattern = trim(input('Search for pattern: ', expand('<cword>')))
if l:pattern == ''
return
endif
let l:pattern = '"' . substitute(l:pattern, '"', '\"', "g") . '"'
echo "\r"
let l:dirs = trim(input('Limit for directory: ', './', 'dir'))
if l:dirs != ''
let l:dirs = '"' . l:dirs . '"'
endif
echo "\r"
let l:files = trim(input('Limit for files pattern: ', '*'))
if l:files == '*'
let l:files = ''
else
let l:files = '-g "' . l:files . '"'
endif
echo "\r"
:echo "GrepperRg " . l:pattern . " " . l:dirs . " " . l:files
:execute "GrepperRg " . l:pattern . " " . l:dirs . " " . l:files
endfunction
nnoremap <silent> <Leader>gr :call <SID>my_run_grep()<CR> So, when I press It speeds up a lot of things for me. If I want to grep for the word in my in my cursor without limiting the directories or the filetypes I can just |
I am using vim-grepper NeoVim plugin that uses new jobstart api to start ripgrep as a background process and uses callback functions to read the produced output. With the new ripgrep version 13.0.0, this plugin stopped working.
I have found that commit 020c545 cause this problem. Just as the comment to this commit suggested, the ripgrep completely blocks forever without reporting any output. Reverting this change, fixes the problem.
Is there a way to provide the command line option to disable checking for sockets in this method?
The text was updated successfully, but these errors were encountered: