I have cloned yasnippets repo repo in ~/.emacs.d/yasnippet-snippets.
I would like to synchronize it each time I start Emacs (btw, it would be nice to do it only if there is a connection available), my current (pretty raw) code is:

;; ~/.emacs
(use-package yasnippet
  (cd "~/.emacs.d/yasnippet-snippets")
  (cd "~/"))

But I am getting this error in *Messages*, probably because it changes directory before finishing the magit process:

error in process sentinel: user-error: Not inside a Git repository
error in process sentinel: Not inside a Git repository

*Using: use-package

  • Both cd and magit-submodule-update are intended for interactive use. I would start by replacing cd with (setq default-directory ...), then add debug statements that print the current-buffer and default-directory to see what's going on.
    – tarsius
    Oct 21, 2016 at 13:53
  • magit-submodule-update runs git asynchronously and returns before it finishes, so putting the yas-reload-all after it will not guarantee that the updated snippets are loaded. Also, yasnippet-snippets repo doesn't have submodules, did you (mean to) clone yasnippet or yasnippet-snippets repo?
    – npostavs
    Oct 21, 2016 at 15:04
  • I think you shouldn't use Magit at all here as that would force you to always load it at startup.
    – tarsius
    Oct 21, 2016 at 15:42
  • @npostavs thanks, instead of using magit I ended up using git directly as suggested in the answer. Also, I was following the advice in the official docs on how to update the repo: git submodule update --init.
    – marcanuy
    Oct 23, 2016 at 3:15
  • The yasnippet repo has yasnippet-snippets as a submodule, so you should run subdmodule update in the yasnippet repo to update yasnippet-snippets. If you did actually clone the yasnippet repo, then it's a bit confusing to have it in a directory named yasnippet-snippets.
    – npostavs
    Oct 23, 2016 at 16:24

1 Answer 1


Something like this would probably work:

(use-package yasnippet
  (let ((default-directory "~/.emacs.d/yasnippet-snippets/"))
    (call-process "git" nil nil nil "pull")))
  • @marcanuy why are you suggesting to replace the let with a setq? Doing so would permanently changes the default-directory of the *scratch* buffer.
    – tarsius
    Oct 23, 2016 at 12:51

Your Answer

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

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