When I try to run magit-commit-popup in Spacemacs, I get the error

Symbol's function definition is void: cl-struct-define

The only reference I could find to this issue was on this Github thread, but I wasn't able to follow what he did to resolve the issue.

My Emacs version is 24.4.2 and I am on Linux Mint 17.2

  • 1
    You have not loaded the file that defines cl-struct-defiine. You need to require it (or load it in another way).
    – Drew
    Commented Jan 18, 2016 at 21:31
  • I don't know how to do that. If you could expand on how to require in Spacemacs, I would love to give it a try though. Commented Jan 18, 2016 at 21:38

2 Answers 2


Exit Emacs. Does the directory ~/.emacs.d/elpa/cl-lib-<version> exist? If so remove it. If not, then remove ~/.emacs.d/elpa/{git-commit,magit,magit-popup,with-editor}-<version> instead. Actually you might want to remove these directories even if the cl-lib directory existed, but first try without doing that.

Then start Emacs. I believe that Spacemacs should now reinstall missing packages. (Not sure though, I don't use Spacemacs. Or package.el.)

Since magit does require cl-lib, there is no need for you to require it yourself. The problem is something else and the above nuclear option should do the trick.

Also, make sure that you are running an up-to-date version of Git. Magit requires at least v1.9.4.

  • Yes, Spacemacs will reinstall the missing packages
    – bmag
    Commented Jan 19, 2016 at 7:53
  • Alternatively M-x spacemacs/recompile-elpa, which will recompile all packages for the current Emacs version.
    – user227
    Commented Jan 19, 2016 at 13:24
  • That did not quite work for me. However, it inspired me to remove elpa directory and installed packages from scratch. That solved it. Commented Jan 11, 2018 at 21:50

I don't if it is the case for you, but this error sometimes happens to people who use multiple versions of Emacs. When installing packages, Emacs also compiles them, but byte-compiled (.elc) files are not 100% compatible between different Emacs version.

As stated in the last comment (by offby1) in the thread you linked, this particular error can happen when installing/compiling packages with Emacs 25, and later loading them with Emacs 24.5 or older. To solve it, you need to recompile the offending files, and there are several ways to do it:

  1. find the offending packages, delete their directories from your elpa directory and let Spacemacs reinstall them. This is what @tarsius suggests in his answer.

  2. find the offending packages and recompile them. Look for Emacs commands that have "byte" and "compile" in their names.

  3. recompile all the packages with the command spacemacs/recompile-elpa, or with the command byte-recompile-directory. Useful if you have many incompatible elc files, or if you don't want to bother pin-pointing the offending packages.

  4. wipe (or move out of the way) your entire elpa directory and restart Emacs, Spacemacs will reinstall all the packages for you. This is a bit extreme and it takes a while to reinstall everything, so I don't recommend it.

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.