TransWikia.com

How to find a file recursively on Microsoft Windows with findutils (gnu find) installed?

Emacs Asked by Vasantha Ganesh on September 2, 2021

I’m trying to find file recursively from default-directory with helm-find (C-x c /). It works out of box in linux.

I tried setting find-program like (I have git bash installed)

(setq find-program "c:/Program Files/Git/usr/bin/find.exe")

It didn’t work.

Then I tried installing findutils (gnu find) from chocolatey and then tried.

(setq find-program "C:/ProgramData/chocolatey/bin/find.exe")

This did not work either. What am I doing wrong?

One Answer

The problem is that helm-find uses find-cmd.el. This find-cmd function generates a GNU find style command that runs without issues on bash, but fails to run on powershell. The default shell in Emacs is PowerShell. If you set your default shell to Git bash (You can follow the steps in this answer to do that.), then it works.

Some Elisp script to do that:

(prefer-coding-system 'utf-8-unix)
(setq shell-file-name "C:\Program Files\Git\usr\bin\bash.exe")
(setq explicit-bash.exe-args '("--login" "-i"))
(setq find-program "C:/ProgramData/chocolatey/bin/find.exe")

Correct answer by Vasantha Ganesh on September 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP