1

I'm having a little trouble with magit and the default-directory variable.

When calling M-x magit-status, an exception is thrown - Setting current directory: No such file or directory, /path/to/git/repo/^M/. I.e. there is an extra carriage return character inserted on the end of the path as though it were another directory level.

For the avoidance of doubt, this is not about carriage returns in a repository file, but rather the path to the repository. Emacs is running on windows, with git for windows.

Error trace below:

Debugger entered--Lisp error: (file-missing "Setting current directory" "No such file or directory" "c:/emacs/home/temp/\015/")
  call-process("c:/Program Files/Git/git-cmd.exe" nil (t nil) nil "--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "i18n.logOutputEncoding=UTF-8" "config" "--list" "-z")
  apply(call-process "c:/Program Files/Git/git-cmd.exe" nil (t nil) nil ("--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "i18n.logOutputEncoding=UTF-8" "config" "--list" "-z"))
  process-file("c:/Program Files/Git/git-cmd.exe" nil (t nil) nil "--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "i18n.logOutputEncoding=UTF-8" "config" "--list" "-z")
  apply(process-file "c:/Program Files/Git/git-cmd.exe" nil (t nil) nil ("--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "i18n.logOutputEncoding=UTF-8" "config" "--list" "-z"))
  magit-process-file("c:/Program Files/Git/git-cmd.exe" nil (t nil) nil "--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "i18n.logOutputEncoding=UTF-8" "config" "--list" "-z")
  apply(magit-process-file "c:/Program Files/Git/git-cmd.exe" nil (t nil) nil ("--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "i18n.logOutputEncoding=UTF-8" "config" "--list" "-z"))
  magit-git-insert("config" "--list" "-z")
  apply(magit-git-insert ("config" "--list" "-z"))
  magit-git-items("config" "--list" "-z")
  magit-config-get-from-cached-list("magit.extension")
  magit-get-all("magit.extension")
  magit-load-config-extensions()
  run-hooks(change-major-mode-after-body-hook special-mode-hook magit-mode-hook magit-status-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook special-mode-hook magit-mode-hook magit-status-mode-hook))
  run-mode-hooks(magit-status-mode-hook)
  magit-status-mode()
  magit-setup-buffer-internal(magit-status-mode nil ((magit-buffer-diff-args ("--no-ext-diff")) (magit-buffer-diff-files nil) (magit-buffer-log-args ("-n256" "--decorate")) (magit-buffer-log-files nil)))
  magit-status-setup-buffer("c:/emacs/home/temp/")
  magit-status(nil ((4 . 4) (("c:/emacs/home/temp/\015/" . magit-toplevel) . "c:/emacs/home/temp/\015/") (("c:/emacs/home/temp/" . magit-toplevel) . "c:/emacs/home/temp/\015/") (("c:/emacs/home/temp/" "rev-parse" "--show-toplevel") . "\015")))
  funcall-interactively(magit-status nil ((4 . 4) (("c:/emacs/home/temp/\015/" . magit-toplevel) . "c:/emacs/home/temp/\015/") (("c:/emacs/home/temp/" . magit-toplevel) . "c:/emacs/home/temp/\015/") (("c:/emacs/home/temp/" "rev-parse" "--show-toplevel") . "\015")))
  call-interactively(magit-status record nil)
  command-execute(magit-status record)
  helm-M-x(nil #("magit-status" 0 12 (match-part "magit-status")))
  funcall-interactively(helm-M-x nil #("magit-status" 0 12 (match-part "magit-status")))
  call-interactively(helm-M-x nil nil)
  command-execute(helm-M-x)
  • Is that actually the value of C-h v default-directory in that buffer? (You've mentioned the variable, but haven't confirmed that it's relevant). If the buffer you're calling magit-status from already has an invalid default-directory, then it's not really a Magit issue. If it's only the Magit status buffer that has the invalid value, please clarify. – phils Oct 31 '19 at 8:56
  • For extra context could you M-x toggle-debug-on-error and then add the stack trace to the question? – phils Oct 31 '19 at 8:56
  • Thanks for the response! default-directory seems to have the path as I would expect - no extra carriage returns. default-directory is a variable defined in ‘C source code’. Its value is "c:/emacs/home/temp/" – jgammon Nov 1 '19 at 1:36
  • Is there a git repo in current dir? Otherwise, what's the value of the variable magit-repository-directories? – JeanPierre Nov 1 '19 at 14:55
  • Current directory is a git repo (temp is just a git repo I setup for this question). Magit-repository-directories has a value of nil – jgammon Nov 6 '19 at 1:19

Your Answer

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

Browse other questions tagged or ask your own question.