8

How can I ensure I'm downloading and using org-plus-contrib from the org-mode repository using require or use-package? Package.el downloads the package, compiles everything and then says it can't load org-plus-contrib. This thread on the mailing list discusses a similar, but inverted problem. However, if I place (use-package org ..., use-package returns t, but does so whether org-plus-contrib is installed or not.

  • Why not simply (use-package org-plus-contrib :ensure t)? Granted that I'm using cask with pallet for package managment, but it places /home/kmicu/.emacs.d/.cask/24.4.1/elpa/org-plus-contrib-20150202 in my path and loads it. – kmicu Feb 2 '15 at 21:57
  • Remember that org-plus-contrib contains org files plus all contribs files. You should install org xor org-plus-contrib, but not both. – kmicu Feb 2 '15 at 22:08
  • Maybe you can try with package-pinned-packages – csantosb Feb 3 '15 at 22:07
4

I'm not 100% sure you can really reliably check with only require or use-package... But if you are using package.el for org-mode functionality, your org-mode configuration may need to be deferred until after your packages have been initialized. You can do this with a hook the runs after Emacs has initialized called "after-init-hook".

So...

That means in your .emacs, you'll need a hook like:

(add-hook 'after-init-hook 'package-config)

And somewhere else:

(defun package-config ()
;;Your org-mode config goes here.
)

After that, you have access to package.el's checking and downloading functionality...

so, since you also want to check for the package's existence, you can use "(package-installed-p 'org-plus-contrib)" and install it with "(package-install package)" if it is not there.

Altogether, the code would probably look something like:

(defun package-config ()
  (unless (package-installed-p 'org-plus-contrib)
    (package-refresh-contents)
    (package-install 'org-plus-contrib)))

(add-hook 'after-init-hook 'package-config)

With the rest of your config being after the (unless ...) body.

That way, you get your configuration, you get your package install checking, and you get it automatically downloaded so you can safely assume that anything past that line in the function can use the loaded contribs. (Assuming you have a network connection if it doesn't exist.)

16

The correct way to do this with use-package is as follows:

(use-package org
  :ensure org-plus-contrib
 ...

The first argument makes sure that it is the org.el file being sourced. The :ensure argument makes sure that you are getting the version with all the extras. Of course you also need to have ("org" . "http://orgmode.org/elpa/") in your package-archives alist.

  • I had no idea ensure didn't have to be a boolean. Good to know! – wdkrnls Oct 23 '15 at 17:01
  • Reference: orgmode.org/elpa.html – Alfred M. Dec 5 '16 at 11:37
  • I'm using this in my config, but whenever a third-party package (e.g., elfeed-org) gets installed with use-package, the default org is downloaded and installed. This cannot be right, any ideas how I can prevent that from happening? – andreas-h Oct 7 '17 at 22:04
0

I do a package-install org-plus-contrib manually, but then subsequently do use-package org. Finally, a subsequent M-x org-version indicates that the org provided by org-plus-contrib is indeed used and all is well.

  • Interesting, do you use any contrib provide functionality? – wdkrnls Sep 7 '15 at 0:34
  • Yes, a few items, though I don't recall which ones at this moment. – Joe Sep 7 '15 at 20:41

Your Answer

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

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