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

When ripgrep is installed, vgrep exits when a file with no read access is in the directory #216

Closed
inknos opened this issue May 16, 2024 · 2 comments · Fixed by #217
Closed

Comments

@inknos
Copy link

inknos commented May 16, 2024

Reproducer:

  1. Install vgrep and ripgrep
  2. Clone vgrep and cd into it
  3. Run sudo touch sudofile
    3.1.
    ls -l sudofile 
    -rw-r--r--. 1 root root 0 16. kvě 17.31 sudofile
    
  4. Run sudo chmod o-r sudofile
    4.1.
    ls -l sudofile 
    -rw-r-----. 1 root root 0 16. kvě 17.31 sudofile
    
  5. Run vgrep something

Results:

searching symbols failed: rg: sudofile: Permission denied (os error 13) [rg]

Expected results:

Index File                                             Line Content
    0 vendor/github.com/jessevdk/go-flags/flags.go       67 Then, the AuthorInfo map can be filled with something like
    1 vendor/github.com/sirupsen/logrus/logger.go        20 // something more adventurous, such as logging to Kafka.
    2 vendor/github.com/sirupsen/logrus/README.md       253 requestLogger.Info("something happened on that request") # will log request_id and user_>
    3 vendor/github.com/sirupsen/logrus/README.md       254 requestLogger.Warn("something not great happened")
    4 vendor/github.com/sirupsen/logrus/README.md       347 // do something here to set environment depending on an environment variable
    5 vendor/github.com/sirupsen/logrus/README.md       494 // gracefully shutdown something...
    6 vendor/github.com/modern-go/concurrent/README.md

Versions:
$ rpm -q vgrep
vgrep-2.6.1-3.fc39.aarch64
$ rpm -q ripgrep
ripgrep-14.1.0-2.fc39.aarch64

Additional information:

Uninstalling ripgrep fixes it. I did some digging and these look like the offending lines. I don't know go much though, so I don't know how to fix it from the top of my head :)

It would be nice to see this fixed, especially because running it like in the README leads to [Command failed: vgrep --no-header 'something'] and it does not really say what's wrong.

@vrothberg
Copy link
Owner

Thanks for reaching out, @inknos ! Always happy to see vgrep being used in the wild :)

Without ripgrep vgrep will try to use git-grep which does not fail when the sudofile hasn't been committed yet. I tried it with --no-ripgrep which also works because vgrep uses git-grep. Adding the --no-git flag will then fail again, because vgrep will then use grep.

What vgrep could do is to parse stdout even in case of an error, and report the error with the same exit code as the underlying grep implementation.

vrothberg added a commit that referenced this issue May 17, 2024
Try parsing the stdout of *grep even in case of an error. This allows to
return output when hitting, for instance, eperms on certain files.

The stderr of *grep is now logged directly while the exit code is being
recorded and used by vgrep on exit.

Fixes: #216
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
@vrothberg
Copy link
Owner

@inknos, do you have time to test PR #217? This should address the issue.

vrothberg added a commit that referenced this issue May 17, 2024
Try parsing the stdout of *grep even in case of an error. This allows to
return output when hitting, for instance, eperms on certain files.

The stderr of *grep is now logged directly while the exit code is being
recorded and used by vgrep on exit.

Fixes: #216
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
vrothberg added a commit that referenced this issue May 20, 2024
Try parsing the stdout of *grep even in case of an error. This allows to
return output when hitting, for instance, eperms on certain files.

The stderr of *grep is now logged directly while the exit code is being
recorded and used by vgrep on exit.

Fixes: #216
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
vrothberg added a commit that referenced this issue May 20, 2024
Try parsing the stdout of *grep even in case of an error. This allows to
return output when hitting, for instance, eperms on certain files.

The stderr of *grep is now logged directly while the exit code is being
recorded and used by vgrep on exit.

Fixes: #216
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
vrothberg added a commit that referenced this issue May 20, 2024
Try parsing the stdout of *grep even in case of an error. This allows to
return output when hitting, for instance, eperms on certain files.

The stderr of *grep is now logged directly while the exit code is being
recorded and used by vgrep on exit.

Fixes: #216
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants