0

I can't get helm-projectile-find-file to work on Windows.

When I run it I get the error message "FIND: Parameter format not correct". Given how similar that is to the native windows find.exe default text I'm guessing that is what it is.

I have the git for windows folder at the very top of my path:

enter image description here

Running find and grep on a cmd.exe terminal do indeed show the the right executable files are being used:

enter image description here

Some other things I have tried:

Add find.exe and grep.exe to the Emacs bin directory

Set the executable path:

(setq exec-path (add-to-list 'exec-path "C:\\\"Program Files (x86)\"\\Git\\bin"))

Set the binary locations:

(setq find-program "C:\\\"Program Files (x86)\"\\Git\\bin\\find.exe"
  grep-program "C:\\\"Program Files (x86)\"\\Git\\bin\\grep.exe")

Same error message in all cases.

1
  • I use the absolute path like this: (setq grep-program "c:/progra~1/GnuWin32/bin/grep.exe")
    – lawlist
    Jan 11, 2017 at 16:48

2 Answers 2

5

This question does not seem to be about Projectile or Helm, but more generally about using grep/find with Emacs on Windows. Have you tried any of the built-in Emacs commands like rgrep, find-grep-dired, etc?

A couple things to try:

  • Evaluate (executable-find "find") to see where Emacs finds the find executable.

  • Evaluate (getenv "PATH") to see what PATH is set to in your Emacs environment.

I've generally found I want to update both exec-path and PATH on Windows. Here's a bit of code I'm currently using to make sure my unix shell tools are ahead of any Windows executables:

;; Windows path
(when (eq system-type 'windows-nt)

  ;; Make sure Unix tools are in front of `exec-path'
  (let ((bash (executable-find "bash")))
    (when bash
      (push (file-name-directory bash) exec-path)))

  ;; Update PATH from exec-path
  (let ((path (mapcar 'file-truename
                      (append exec-path
                              (split-string (getenv "PATH") path-separator t)))))
    (setenv "PATH" (mapconcat 'identity (delete-dups path) path-separator))))

This finds my unix bin dir (by looking for bash) and makes sure it is at the front of exec-path. Then I change the PATH variable to match the exec-path.

Update: Details about projectile use of find

A few details about projectile, if this is really specific to projectile:

  • On Windows, projectile defaults to setting projectile-indexing-method to native, which does not use external tools like find. If it is calling find then you may have changed the configuration to use alien indexing, which looks for external tools.

  • If you use alien indexing, projectile will first check if the project uses a version control tool that provides fast searching, e.g. git. Otherwise it will fall back to using projectile-generic-command.

  • The default value for projectile-generic-command is "find . -type f -print0". Note that this is a string passed to shell-command-to-string, and so it expects that the shell will have find on the PATH. Changing e.g. find-program and exec-path are not relevant here, since those do not affect a shell process created by Emacs.

So if projectile is failing to use the right find command, you probably want to make sure that your shell (as determined by shell-file-name) is running with the right PATH. As I noted above, you can setenv PATH within Emacs, and this will affect the environment of shell processes that Emacs creates.

1
  • Thanks for a very thorough answer. That windows setup code is very nice indeed.
    – user14510
    Jan 14, 2017 at 1:19
0

OK so I finally figured this out. Everything was set up correctly but projectile seems to remember the last place it found the find.exe. After deleting all of the projectile related files from my .emacs.d fold helm-projectile-find-file began to work.

1
  • Glad you sorted it out, but I very much doubt that Projectile had cached anything about the find command. I've added some more info to my answer about how Projectile actually uses find. It seems most likely that you either restarted Emacs after getting your system PATH set properly, or that some configuration file you removed was changing the default projectile-indexing-method to use alien rather than native.
    – glucas
    Jan 11, 2017 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.