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

Expansion of ~ on Windows #7

Closed
elge70 opened this issue Dec 17, 2023 · 4 comments
Closed

Expansion of ~ on Windows #7

elge70 opened this issue Dec 17, 2023 · 4 comments

Comments

@elge70
Copy link

elge70 commented Dec 17, 2023

If the project is under HOME directory on windows (where HOME env variable has been defined), none of the grep utilities works correctly. But it works correctly under linux. Probably we may have to use (expand-file-name) to get the absolute path of the directory

-*- mode: urgrep; default-directory: "~/Repo/xxxx/AsyncFamily/" -*-
Urgrep started at Sun Dec 17 18:05:33

rg --color=always "--colors=path:none" "--colors=path:fg:magenta" "--colors=line:none" "--colors=column:none" "--colors=match:none" "--colors=match:fg:red" "--colors=match:style:bold" --heading -F -- myStore

@jimporter
Copy link
Owner

jimporter commented Dec 17, 2023

This works fine for me. Emacs already expands default-directory as necessary before starting the child process. (For example, if I call M-x compile cd RET on Windows under $HOME, it correctly prints c:\Users\user\....) I've also tried using find+grep on Windows (which is what I have installed) via Urgrep, and it searches under my home directory correctly.

Urgrep isn't doing anything special with the default-directory here, other than what compilation-mode does. So if there's a bug here, I don't see how it could be in this package. It's likely in one of:

  1. Your configuration (try emacs -Q -l /path/to/urgrep.el to see if it still happens?)
  2. Emacs itself (try running M-x compile and entering your Ripgrep command to see what happens)
  3. Ripgrep

@elge70
Copy link
Author

elge70 commented Dec 18, 2023

I use project.el to open the project and files. I use ripgrep to search for pattern and it is not working. The project stores the path of project in .emacs.d/projects file as "~/Repo" etc. That could be the problem. This problem is not seen if I am using consult-ripgrep. This can be reproduced with ugrep also.

@jimporter
Copy link
Owner

jimporter commented Dec 18, 2023

I use project.el to open the project and files. I use ripgrep to search for pattern and it is not working. The project stores the path of project in .emacs.d/projects file as "~/Repo" etc. That could be the problem. This problem is not seen if I am using consult-ripgrep. This can be reproduced with ugrep also.

The actual value of default-directory should already be expanded, so I strongly doubt that the ~ has any effect.

I believe the issue you're seeing is this: BurntSushi/ripgrep#951. I guess that means that Urgrep needs a special-case for ripgrep to always include a directory as an explicit command argument, else it will hang waiting for stdin that never arrives (but only on Windows, since Emacs can't use PTYs to communicate with child processes there).

@jimporter jimporter reopened this Dec 18, 2023
jimporter added a commit that referenced this issue Dec 18, 2023
This was broken because ripgrep/ugrep assume you're piping data in to search if
stdin is a pipe. Since Emacs only uses pipes for child processes on Windows,
things get confused. The solution is to always pass the search directory to
ripgrep/ugrep, even when it's just ".".
@jimporter
Copy link
Owner

@elge70 Could you try this branch to see if things work? https://github.com/jimporter/urgrep/tree/ripgrep-windows

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

No branches or pull requests

2 participants