Wednesday, May 14, 2008

Emacs error in setenv, Wrong type argument: stringp

Hey, this isn't a regular blog post, just a contribution to the Emacs community. Hopefully this will get picked up by Google and help out a fellow Emacs user.

I started getting this error whenever I ran M-x grep-find:

Wrong type argument: stringp, 70
Here's the important part of the stack trace:
Debugger entered--Lisp error: (wrong-type-argument stringp 70)
string-match("\\`GREP_OPTIONS=" 70)
setenv("GREP_OPTIONS" " --color=always")
Eventually I figured out to look at the process-environment variable, which holds all the variables set by setenv.
process-environment is a variable defined in `C source code'.
Its value is
(70 79 79 61 98 97 114 "TERM=dumb" "TERMCAP="...
So there it is. string-match is choking on the non-string value 70 in the process environment. And where was that coming from? I searched my .emacs file only to find the following line, left over from some failed experiment:
(setq compilation-environment "FOO=bar")
This would execute without an error but leave the process-environment in a bad state.

Moral of the Story

If you're having a problem with setenv or getenv, or any compilation process, check process-environment and make sure it's properly formed.

Friday, May 9, 2008

"It goes from the Cheesecake Factory to Hooters"

--Seattle Post Intelligencer's D. Parvaz on the eminent usefulness of the new streetcar.