progfolio / elpaca

An elisp package manager
GNU General Public License v3.0
650 stars 33 forks source link

[Support]: Using org-babel-load-languages #264

Closed bmp closed 8 months ago

bmp commented 8 months ago

Confirmation

Elpaca Version

Elpaca 09a94ca HEAD -> master, origin/master, origin/HEAD installer: 0.6 emacs-version: GNU Emacs 29.2 (build 2, x86_64-unknown-linux-gnu, GTK+ Version 3.24.38, cairo version 1.18.0) of 2024-01-20 git --version: git version 2.43.2

Operating System

OS: Void x86_64 Kernel: 6.6.16_1

Description

I use the following in my init.el with both straight.el and use-package based on a wonderful guide by Norang,

;; active Babel languages
  (org-babel-do-load-languages
   (quote org-babel-load-languages)
   (quote ((shell . t)
           (dot . t)
           (org . t)
           (R . t)
           (python . t)
           (latex . t)
           (emacs-lisp . t)
           (latex . t)
           (java . t))))

It worked perfectly well previously, however with elpaca, I get the following warning,

⛔ Warning (emacs): Org version mismatch.
This warning usually appears when a built-in Org version is loaded
prior to the more recent Org version.

Version mismatch is commonly encountered in the following situations:

1. Emacs is loaded using literate Org config and more recent Org
   version is loaded inside the file loaded by ‘org-babel-load-file’.
   ‘org-babel-load-file’ triggers the built-in Org version clashing
   the newer Org version attempt to be loaded later.

   It is recommended to move the Org loading code before the
   ‘org-babel-load-file’ call.

2. New Org version is loaded manually by setting ‘load-path’, but some
   other package depending on Org is loaded before the ‘load-path’ is
   configured.
   This "other package" is triggering built-in Org version, again
   causing the version mismatch.

   It is recommended to set ‘load-path’ as early in the config as
   possible.

3. New Org version is loaded using straight.el package manager and
   other package depending on Org is loaded before straight triggers
   loading of the newer Org version.

   It is recommended to put

    (straight-use-package 'org)

   early in the config.  Ideally, right after the straight.el
   bootstrap.  Moving ‘use-package’ :straight declaration may not be
   sufficient if the corresponding ‘use-package’ statement is
   deferring the loading.

4. A new Org version is synchronized with Emacs git repository and
   stale .elc files are still left from the previous build.

   It is recommended to remove .elc files from lisp/org directory and
   re-compile.
⛔ Warning (org-element): org-element--cache: Org parser error in bmp_old.org::156. Resetting.
 The error was: (wrong-number-of-arguments #<subr org-get-limited-outline-regexp> 1)
 Backtrace:
nil
 Please report this to Org mode mailing list (M-x org-submit-bug-report).
⛔ Warning (org-element): org-element--cache: Org parser error in bmp_old.org::8. Resetting.
 The error was: (wrong-number-of-arguments #<subr org-get-limited-outline-regexp> 1)
 Backtrace:
nil
 Please report this to Org mode mailing list (M-x org-submit-bug-report).
⛔ Warning (org-element): org-element--cache: Org parser error in bmp_old.org::98697. Resetting.
 The error was: (wrong-number-of-arguments #<subr org-get-limited-outline-regexp> 1)
 Backtrace:
nil
 Please report this to Org mode mailing list (M-x org-submit-bug-report).
⛔ Warning (org-element): org-element--cache: Org parser error in bmp_old.org::98090. Resetting.
 The error was: (wrong-number-of-arguments #<subr org-get-limited-outline-regexp> 1)
 Backtrace:
nil
 Please report this to Org mode mailing list (M-x org-submit-bug-report).
progfolio commented 8 months ago

Thanks for taking the time to fill out a support ticket. The warning sums up the situation:

a built-in Org version is loaded prior to the more recent Org version

This means that the Org feature has been loaded prior to your use-package declaration for Org. This often happens when one of Org's features is used early in the init file (e.g. Users loading their config with org-babel-load-file). If you have a link to your init file, I'd be happy to take a look and diagnose the issue. Alternatively you can add the following elisp to the beginning of your init file. It should cause the debugger to show a backtrace. The backtrace will show exactly when and what is causing Org to be loaded.

(eval-after-load "org" '(debug))

If you're having trouble interpreting the output of the backtrace, feel free to share it's full text here and I will take a look.

Let me know if that helps.

bmp commented 8 months ago

Thank you for the offer to look at the init file, I'll need to remove all the personal info in it before I can put it up online. I do have my init file in an org file, but I do not load it throught that mode, I tangle the file and then place it in the .emacs.d folder.

In the meantime, I added the (eval-after-load "org" '(debug)) into the init file and here is the backtrace,

Debugger entered: nil
  (closure (t) nil (debug))()
  funcall((closure (t) nil (debug)))
  do-after-load-evaluation("/usr/share/emacs/29.2/lisp/org/org.elc")
  (org-babel-do-load-languages 'org-babel-load-languages '((shell . t) (dot . t) (org . t) (R . t) (python . t) (latex . t) (emacs-lisp . t) (latex . t) (java . t)))
  load-with-code-conversion("/home/bmp/.emacs.d/init.el" "/home/bmp/.emacs.d/init.el" t t)
  load("/home/bmp/.emacs.d/init" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x10e71e71dc9d5432>) #f(compiled-function () #<bytecode -0x1f3c61addc0acb35>) t)
  command-line()
  normal-top-level()
progfolio commented 8 months ago

(org-babel-do-load-languages 'org-babel-load-languages '((shell . t) (dot . t) (org . t) (R . t) (python . t) (latex . t) (emacs-lisp . t) (latex . t) (java . t))) load-with-code-conversion("/home/bmp/.emacs.d/init.el" "/home/bmp/.emacs.d/init.el" t t) load("/home/bmp/.emacs.d/init" noerror nomessage)

It looks like these forms are at the top level of your init file. They need to be deferred so Elpaca can load Org first. e.g.

With use-package/elpaca-use-package-mode:

(elpaca elpaca-use-package (elpaca-use-package-mode))
(elpaca-wait)
(use-package org
  :ensure t ;; This will install the dev version of Org
  ;; :ensure nil would use the built-in version of Org
  :config
  ;; your Org config goes here
  )

Or without use-package:

(elpaca org
  ;;Org config goes here
  )

Does that make sense?

bmp commented 8 months ago

I actually was loading this portion babel much after I was loading org package. I have now moved it into tho the config portion like this,

(use-package org
    :ensure t
    :bind
    (:map org-mode-map
          ("C-M-<return>" . org-insert-subheading))
    :config
    ;; Bunch of other config
    ;; active Babel languages
    (org-babel-do-load-languages
     (quote org-babel-load-languages)
     (quote ((shell . t)
             (dot . t)
             (org . t)
             (R . t)
             (python . t)
             (latex . t)
             (emacs-lisp . t)
             (latex . t)
             (java . t)))))

This portion works now, thank you so much!

progfolio commented 8 months ago

I actually was loading this portion babel much after I was loading org package. I have now moved it into tho the config portion like this,

Because Elpaca is asynchronous, the use-package form was being deferred and the part that was "after", lexically speaking, was being evaluated first.

Moving the configuration into the use-package declaration defers its evaluation as well.

This portion works now, thank you so much!

Glad to hear it. Thank you.