5

Is there a way to tell package.el that the org-plus-contrib package I already have satisfies any dependency on org, so that installing packages that depend on org (such as the afore mentioned org2blog) doesn't automatically install org as well?

This is not an actual problem: after installing org2blog through the Package menu I now have org installed in addition to org-plus-contrib (which includes all of org). This extra org doesn't load (when I run M-x org-version I can see that I get the one from org-plus-contrib) or bother me in any way. But since I'm not using it, I'd rather not have it.

I bet the "right way" to fix this is for the org-plus-contrib package to be reduced to an org-contrib package that depends on org and only contains the extra libraries, not the org base. But is there anything locally I can do to fix this (very minor) annoyance?

3

I have tested below to work with the in-built package.

Below snippet will prevent installation of packages (package symbol) listed in the let-bound pkg-black-list variable in the below function.

For example, after evaluating the below, doing M-x package-install ox-asciidoc will not install the org package. You will see the below in the *Messages* buffer:

Package ‘org’ will not be auto-installed. See ‘modi/package-dependency-check-ignore’.


(defun modi/package-dependency-check-ignore (orig-ret)
  "Remove the `black listed packages' from ORIG-RET.

Packages listed in the let-bound `pkg-black-list' will not be auto-installed
even if they are found as dependencies.

It is known that this advice is not effective when installed packages
asynchronously using `paradox'. Below is effective on synchronous
package installations."
  (let ((pkg-black-list '(org))
        new-ret
        pkg-name)
    (dolist (pkg-struct orig-ret)
      (setq pkg-name (package-desc-name pkg-struct))
      (if (member pkg-name pkg-black-list)
          (message (concat "Package `%s' will not be installed. "
                           "See `modi/package-dependency-check-ignore'.")
                   pkg-name)
        (push pkg-struct new-ret)))
    ;; It's *very* critical that the order of packages stays the same in NEW-RET
    ;; as in ORIG-RET. The `push' command flips the order, so use `reverse'
    ;; to flip the order back to the original.
    ;;   Without this step, you will get package activation errors when
    ;; installing packages with dependencies.
    (setq new-ret (reverse new-ret))
    new-ret))
(advice-add 'package-compute-transaction :filter-return #'modi/package-dependency-check-ignore)

This will not work when installing packages asynchronously using the paradox package. You can still use the paradox package, but you would need to pick the synchronous installation option.

  • This great, thanks! I'll use something just like this but making pkg-black-list a customizable variable. – Omar Aug 24 '16 at 18:02
  • I think I'll also add the possibility of using regular expressions in pkg-black-list. – Omar Aug 24 '16 at 18:18
  • @OmarAntolín-Camarena In that case, make the black list a string list and (setq pkg-name (symbol-name (package-desc-name pkg-struct))). – Kaushal Modi Aug 24 '16 at 18:31
  • Yes, that's what I did, @KaushalModi, and instead of member I join all the black listed strings with "\\|" and use string-match-p. – Omar Aug 24 '16 at 20:36
3

I use quelpa to fake package name org:

(quelpa '(org :url "git://orgmode.org/org-mode.git" :fetcher git
            :files ("lisp/*.el" "contrib/lisp/*.el" "doc/dir" "doc/*.texi") :upgrade nil))

With this snippet, you will have master branch of git repo. ELPA version comes from maint branch, so you may have versions gap. Please tweak its branch with your preference.

  • Thanks for this answer, I didn't know about quelpa and it looks pretty interesting, but since I'm happy with the builtin package.el I'm looking for an answer geared towards it. – Omar Aug 24 '16 at 18:00

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.