When I run compile, I'm seeing a strange behavior where the shell command is being executed in the parent of default-directory rather than default-directory itself. Here's an example of what I'm doing:

(let ((default-directory "~/projects")) (compile "pwd"))

And here's what shows up in the *compilation* buffer:

-*-mode: compilation; default-directory: "~/projects/" -*- Compilation started at Sun Jan 18 14:03:45 pwd /Users/sixtynorth Compilation finished at Sun Jan 18 14:03:45

As you can see, on the first line of *compilation* the default-directory is correct. But when pwd actually executes I've been changed to the parent directory. This behavior seems consistent across different directories, commands, etc.

Does anyone have any idea what might be going on? I've poked through the compile code, but nothing looks suspicious. I've also looked in my shell configuration for anything that might be causing problems, but again nothing jumped out at me. Any thoughts or ideas would be great.

  • FWIW, this occurs with a completely empty .emacs. This is on OSX. emacs-version reports "GNU Emacs 24.4.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21) of 2014-12-15 on achewood.local".
    – abingham
    Jan 18, 2015 at 13:18

1 Answer 1


The value of default-directory has to end with a slash.

  • 1
    heh...yep, it even says it right there in the documentation. I must have read past that 100 times. Thanks!
    – abingham
    Jan 18, 2015 at 13:50

Your Answer

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

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