3

This question already has an answer here:

I have the following code in my init.el file:

(use-package org-plus-contrib
  :ensure t
  :config (progn (require 'ox-extra)
          (ox-extras-activate '(ignore-headlines))))

The :ensure t supposedly installs the package if it is not already installed. Without it, I would get a warning message telling me the package cannot be loaded.

However, even with :ensure t I still get the warning: Error (use-package): Cannot load org-plus-contrib. This also occurs with other packages (spacemacs-theme, matlab-mode). But it does properly work for many other packages (org, all-the-icons,doom-themes,neotree, exec-path-from-shell).

Question: Why is this happening and how I can fix it?

Thanks for the help! :D

marked as duplicate by npostavs, Stefan, Drew, Community Aug 9 '18 at 16:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    First thing to try is emacs --debug-init to see if you can get further information from the stack trace. Post the output that you get from that and it will be easier to get help. – MTS Aug 8 '18 at 18:57
  • @MTS I'm not sure how to do it. I use emacs with GUI, if I start it on terminal I don't get the GUI version, and there are things in the init.el that will be messed up because of that. – Guilherme Salomé Aug 8 '18 at 22:11
  • What OS are you on? What version of emacs are you using? How did you install it? Calling emacs from the terminal for me starts the GUI version. If you read the man page for emacs you will see that there is an option --no-window-system to force opening emacs in a terminal. I don't see a corresponding option to force opening the GUI version and as far as I know the GUI version is the default. – MTS Aug 8 '18 at 23:48
  • In any case you can try putting (setq debug-on-error t) near the top of your init.el and just start emacs the way you normally would. It should enter the debugger when you encounter the error. – MTS Aug 8 '18 at 23:49
  • 1
    org-plus-contrib and org with require or use-package is also pretty similar; my dup target suggestion is more general and has an answer with a thorough explanation. – npostavs Aug 9 '18 at 1:31
4

The symbol you must give use-package is not the name of the package, but the name of a feature provided by the package. org-plus-contrib provides the org feature. You should use

(use-package org
  :ensure org-plus-contrib
  :config
  (require 'ox-extra)
  (ox-extras-activate '(ignore-headlines)))

The :ensure keyword can take t meaning the name of the package is the same as the feature to be required, or it can take the name of the package (here org-plus-contib).

(I also took the liberty of removing the unnecessary progn.)

  • Wow, thanks Omar! I did not understand what you mean by feature, could you elaborate a little more? I thought the symbol I should give use-package was the name of the package as in the repository. In this case, it was org-plus-contrib the name of the package that I was trying to ensure was downloaded. What about in the case of matlab-mode? – Guilherme Salomé Aug 9 '18 at 1:02
  • 1
    @GuilhermeSalomé "Features" are the things you can require in Emacs, and that Elisp files can provide. The matlab-mode package has a matlab.el file with a line that says (provide 'matlab). When you (require 'matlab) Emacs wants to load a file that has such a line. Which file will have it? Well, require has an optional second argument where you tell it which file to load, but if you don't provide it it guesses the name of the file is the same as the name of the feature. (This is just like :ensure t guessing that the name of the package is the same as the name of the feature.) – Omar Aug 9 '18 at 18:44

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