Skip to content
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 exits with 1 when ran from within neovim #35

Closed
flybayer opened this issue Sep 23, 2016 · 10 comments
Closed

rg exits with 1 when ran from within neovim #35

flybayer opened this issue Sep 23, 2016 · 10 comments
Labels
bug A bug.

Comments

@flybayer
Copy link

I'm trying to use rg with ag.vim. I have the following in my vim config:

let g:ag_prg="rg --no-heading --vimgrep"

However, it never returns results.

It turns out that when trying to run it from the vim command line it exits with 1 instead of giving results:
image

The same thing works fine with ag:
image

Running rg --no-heading --vimgrep from the terminal works fine.

Here's trying to run rg in vim with --debug:
image

Any ideas?

@BurntSushi
Copy link
Owner

Are you sure your search is taking place in the right directory and actually returns results? I can run :!rg --vimgrep foo in my vim just fine.

It might help to try running :!rg --files to see precisely what it's trying to search.

@flybayer
Copy link
Author

@BurntSushi This is weird..

:!rg --files prints out the files properly

However, :!rg appName returns 1

@elasticdog
Copy link

Just to confirm the reported issue, I'm also seeing this behavior with the shell returned 1 from rg where ag works as expected. This is using NeoVim (NVIM v0.1.6-120-g4a6b4bb) on OS X 10.11.6 for what it's worth. When I add the --files flag, it does output the expected list of files, but always exits with 1, as far as my limited testing has shown.

@flybayer
Copy link
Author

Thanks @elasticdog

I'm using NeoVim on Ubuntu 14.04 with oh-my-zsh.

@BurntSushi
Copy link
Owner

Interesting, I can finally reproduce this in neovim (Linux), but vim works fine (Linux, Mac).

Only thing I can think of is that rg thinks its getting stdin piped, so it tried to read it, finds nothing, and reports failure. I'll dig into it.

@little-dude
Copy link
Contributor

could it be due to this? Quoting:

This is not a bug, it is the new behavior of bang commands: We no longer spawn the program with it's stdout connected to Nvim tty, instead we open a pipe, read output and display to the user. This is the only way the bang commands will be consistent across UIs, so programs designed to be used interactively from the terminal will no longer work from inside nvim.

@BurntSushi BurntSushi added the bug A bug. label Sep 24, 2016
@jonboiser
Copy link

jonboiser commented Sep 24, 2016

I'm running into something similar trying to add rg to atom-fuzzy-grep.

rg --ignore-case --with-filename --no-heading --column produces output compatible to ag.

Testing with rg --files works fine, but with any other flags, the process exits with code 1. I'm not a Node expert, but I think the library author sets the stdio options for ChildProcess to ignore stdin link.

@BurntSushi BurntSushi changed the title rg exits with 1 when ran from within vim rg exits with 1 when ran from within neovim Sep 24, 2016
@BurntSushi
Copy link
Owner

This should be fixed now. rg was being a bit too aggressive with trying to read from stdin. It will now only try if it's given a file or a FIFO.

@remi
Copy link

remi commented Sep 25, 2016

@BurntSushi Awesome! Do you plan to release a new version soon? Thank you! 😄

@BurntSushi
Copy link
Owner

I'd like to get a release out today. I'm just trying to cram as many fixes in as I can. :-)

amsharma91 added a commit to amsharma91/ripgrep that referenced this issue Sep 27, 2016
If no paths are given to ripgrep, only read from stdin if it's a file or
a FIFO. In particular, if something like `rg foo < /dev/null` is used,
then don't try to read from stdin.

Fixes BurntSushi#35, BurntSushi#81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug.
Projects
None yet
Development

No branches or pull requests

6 participants