Andy
Andy

Reputation: 2997

Grep failing with Emacs (windows), and GnuWin32 Grep

I've downloaded and installed the GnuWin32 tools, and added the grep executables to the Emacs bin. I've also, for what its worth, added the GnuWin32 bin folder to my Path variable.

Problem is though, when I try and run with suggested grep commands, I always get:

Grep exited abnormally with code 53 at Wed Feb 24 17:16:12

For the life of me, I can't find any reference to error code 53 anywhere! :(

I've tried the exact examples on a number of websites for example, when I enter:

M-x grep <ret>

It comes up with

Run grep (like this): grep -n 

Which is fine, but I have no idea of what parameters it expects. I've tried some in some tuorials, but I get error code 53 again!

One of the things I've tried is straight from the emacs wiki (http://www.emacswiki.org/emacs/GrepMode#toc2) (maybe not for the windows version though?) and it says to try this command:

M-x grep -n -e setq ~/.emacs

Which I've tried and I get:

-*- mode: grep; default-directory: "c:/[My Directory]/" -*-
Grep started at Wed Feb 24 17:30:47

grep -n -e setq ~/.emacs NUL

Grep exited abnormally with code 53 at Wed Feb 24 17:30:47

So frustrating as this is meant to be a powerful feature of Emacs and I'm really trying to learn it as I've heard good things about it!

Any help would be appreciated! :)

Andy

UPDATE

From the suggestion below, I've tried it via command line and it seems to work fine, perhaps there some config I'm missing?

UPDATE

I've found the command M-x Occur which seems to do much the same as I would image grep does. Are there many extra benefits to using grep over occur if I can't get this working?

Upvotes: 4

Views: 5228

Answers (3)

Binh Nguyen
Binh Nguyen

Reputation: 124

I had a similar problem and the following worked for me.

  1. Go to the windows console
  2. Enter the command "set" to bring up your system variables
  3. I had shell=c:\progra~1\rational\ration~1\nutcroot\mksnt\sh.exe
  4. Enter "set shell=" to remove the variable
  5. Try Emacs again

Good luck!

Upvotes: 1

Marius Andersen
Marius Andersen

Reputation: 922

Download the dependencies zip file and copy libiconv2.dll, libintl3.dll, pcre3.dll and regex2.dll to Emacs' bin directory.

Copy grep.exe and find.exe to Emacs' own bin directory. Emacs will then use these files over any other executables with the same name, including Windows' own find utility.

Note: if you don't use the installer, you need to download the dependencies zip file as well and copy libiconv2.dll, libintl3.dll, pcre3.dll and regex2.dll to Emacs' bin directory, otherwise you may get an "exited abnormally with code 53" error message.

EmacsWiki: Grep Mode

Upvotes: 5

luapyad
luapyad

Reputation: 3900

The exit code of 53 is possibly an OS exit code rather than a grep-specific exit code. For windows this would be "The network path was not found". Are you doing anything over a network path? Are there any missing dll's that grep needs? Can you successfully run grep on the command line?

Upvotes: 1

Related Questions