phiresky / ripgrep-all

rga: ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc.
Other
8.21k stars 177 forks source link

Unable to open a searched file on macOS #240

Open h4rsh-k opened 3 months ago

h4rsh-k commented 3 months ago

Describe the bug I search for some using rga-fzf foo and then do a enter on the file name in the results sidebar. However I am getting an error - Error: No such file or directory (os error 2)

To Reproduce

Attach example file:

Run command:

Output

Screenshots If applicable, add screenshots to help explain your problem.

image

Operating System and Version MacOS Sonoma 14.1.2

Output of rga --version ripgrep-all 0.10.6 - Installed via homebrew

justinmayer commented 2 months ago

I can confirm these same errors with ripgrep-all 0.10.6, installed via Homebrew on MacOS Sonoma 14.7. I had to revert to the shell functions listed in the wiki.

yunake commented 1 month ago

It's hardcoded to try Evince, and xdg-open barring that: https://github.com/phiresky/ripgrep-all/blob/dcbcb7147f70baef10177177b50ac482f868ace8/src/bin/rga-fzf-open.rs#L16

It's needs to use open on MacOS instead. You can either install Evince, alias it, use a modified script from the wiki or change the code yourself and recompile.

phiresky commented 1 month ago

the rga-fzf-open script is pretty hacky in general. I should probably remove or replace it with something more clean / configurable

justinmayer commented 1 month ago

@yunake: The current behavior seems to only try evince for PDF files, so installing Evince alone is not sufficient as a workaround if you plan to open any other (non-PDF) file types. As a temporary workaround, the following was sufficient for me:

ln -s /usr/bin/open $HOME/.local/bin/xdg-open

@phiresky: Personally, I believe the bundled script has value. Rather than removing it, I suggest a fix along the lines of the above-linked pull request. Then perhaps a subsequent iteration with more configurability would also be very welcome. 😊

phiresky commented 1 month ago

Well the only reason why evince is hard coded is because it actually opens the find menu on evince (via --find) and thus scrolls the PDF automatically to the appropriate section. So replacing that needs a syntax to allow that for arbitrary file types and arbitrary operating systems, if it's the same for each file extension then the script is kind of pointless, and since custom adapters exists it also needs to be configurable