2

Typing this command on regular cmd.exe or cygwin termal gives me results as expected:

$ ack hello

(I have ack.bat that execute ack.pl in my PATH)

However, when I run the same command from either shell or eshell in Emacs, it gives me this error:

c:\Users\Martin>"C:\cygwin\bin\perl" /cygdrive/c/Users/Martin/Desktop/ack.pl hello 
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LC_ALL = (unset),
    LANG = "ENU"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

I tried to fix it by SETENV both variable to en_US.UTF-8 but when I run it again, it gave me no result but froze.

Update: I have finally found the solution to this problem. All I need was to add < NUL to the end of the command since it parse Linux style NULL DEVICE as default.

Now if I type in this:

ack hello < NUL

It'll give me results as expected.

  • 1
    In Cygwin (which uses bash), you want to use `export VAR=VALUE`, not `SETENV var=value`. – mob Jan 11 '13 at 18:40
  • I used SETENV from emacs command. Anyway, I tried "export" it's still the same as SETENV. Perl no longer gave me locale warning but it didn't show me any result but froze(I can't even C-c C-c). [screenshot](http://i.imgur.com/40PGW.png) – user1970791 Jan 11 '13 at 18:58
  • Also see the `ack --nofilter` flag. – MidLifeXis Sep 24 '13 at 17:02
  • 1
    You should not edit your question to include an answer, even if the answer is yours. Instead post it as an answer and accept it (if it answers your question well). – Palec Jan 31 '14 at 13:41

1 Answers1

0

This problem doesn't have to do with ack per se, but pearl, the language Ack is written in. What perl reports is that your environment where you are running emacs does not have the locale settings set. Add the following lines to whatever environment you're running emacs in:

export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Note: running ack hello < NUL only masks the problem, it doesn't resolve it.

gregory
  • 10,969
  • 2
  • 30
  • 42