4

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

  • 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 08 '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 08 '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 08 '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 08 '18 at 23:49
  • @MTS replying to your first comment: GNU Emacs 26.1 (build 1, x86_64-apple-darwin13.4.0, Carbon Version 157 AppKit 1265.21) – Guilherme Salomé Aug 08 '18 at 23:57
  • @MTS using `debug-on-error` doesn't really do anything, I guess it is because `use-package` does not throw an error, just a warning message – Guilherme Salomé Aug 08 '18 at 23:59
  • 1
    [org-plus-contrib and org with `require` or `use-package`](https://emacs.stackexchange.com/questions/7890/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 09 '18 at 01:31
  • @npostavs thanks for the suggestions, those indeed explain the issue very well. The answer provided by @Omar below is still useful, since it also clarifies that the use of `:config` for multiple function calls does not need a `progn`. – Guilherme Salomé Aug 09 '18 at 11:42

1 Answers1

7

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.)

Omar
  • 4,732
  • 1
  • 17
  • 32
  • 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 09 '18 at 01:02
  • 2
    @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 09 '18 at 18:44