1

On one computer I use, my emacs will always run commands in my home directory, rather than the directory of the currently open file (i.e. default-directory).

A standalone reproduction is executing the following:

(let ((default-directory "/tmp/")) (compile "pwd"))

On the computer in question, it prints the path to my home, not /tmp as it does on all other computers-with-emacs I have access to. (The same thing happens with M-!/M-x shell-command.)

I recently installed 24.5 into my user folder (the global install is 23.4), and installed Emacs Prelude but the behaviour described above happened/happens in all configurations (it certainly happened before I made any modifications) and happens if I run emacs -Q (for both 24.5 and 23.4) to avoid reading my configurations (as lawlist asks).

If there's no obvious problem/fix, is there a good way to start to debug a problem like this?

  • 1
    Does it happen when you start Emacs with absolutely no user configuration whatsoever? Emacs -Q If not, then consider bisecting your user configuration (commenting stuff out) until you find the culprit. – lawlist Oct 7 '15 at 0:08
  • @lawlist, yes, it does still happen unfortunately. – huon Oct 7 '15 at 2:27
  • 1
    Looks like your shell is doing something. What OS are you running? What shell? What happens if you start a new shell in a terminal in a non-default directory? Try running your shell with the -x option if it's a typical Unix shell (bash, zsh, tcsh, …). – Gilles Oct 7 '15 at 14:27
1

After experimenting with overriding $HOME and tracking some things through with bash -x as @Gilles suggested, I found my ~/.bash_profile included an isolated cd command, meaning the shell emacs spawned to compile/run commands was always left in my home directory.

(Annoying, and apparently my fault, although I have no idea how that cd got there.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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