emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Bug? org-assert-version does not prevent mixed install
Date: Wed, 4 Jan 2023 18:27:00 +0700	[thread overview]
Message-ID: <tp3nq5$fsf$1@ciao.gmane.io> (raw)
In-Reply-To: <87a63797yc.fsf@localhost>

Ihor,

I am still puzzled why you can not reproduce messed version compilation 
issue. I can not figure out what I am missing. I think, the case below 
is easier than dealing with packages:

Consider the following file compile-broken.el where ~/src/org-mode
contains git main HEAD version:

(load "org")
(let ((org-dir "~/src/org-mode/lisp"))
   (add-to-list 'load-path org-dir)
   (byte-recompile-directory org-dir 0 :force))

remove lisp/*.elc files, run "make autoloads" and

     emacs -Q -l compile-broken.el

It causes messed version compilation.

Side note: On attempt to quit (C-x C-c) I get
org-clock-kill-emacs-query: Symbol’s function definition is void: 
org-clocking-buffer
and I had to use `kill-emacs' at this point. Exit hooks should not be so 
aggressive.

Next session demonstrates the issue:

     emacs -Q -L ~/src/org-mode/lisp/ -l org

There is a way to get Org completely broken. Let's simulate pulling of 
bundled org through some dependency and configuring new directory 
afterwards:

     emacs -Q  -l org --eval "(add-to-list 'load-path 
\"~/src/org-mode/lisp/\")" /tmp/test.org

Version mismatch is not detected, but RET causes

    eval-buffer: Symbol’s function definition is void: org-assert-version

I have no idea how to fight with such cases.

If you still can not reproduce with Emacs <= 28.1 then I may only 
suggest to check (locate-library "org-macs") and to remind about 
(list-load-path-shadows). I have no other ideas besides your environment 
is not clean and development Org version is available to Emacs.

On 28/12/2022 16:46, Ihor Radchenko wrote:
> Max Nikulin writes:
>>
>> Notice that `org-assert-version' works for compiled files only.
> 
> I think that most reliable approach in this situation would be pulling
> `org-assert-version' into a dedicated new file, similar to what you
> suggested below. That way, we will not have feature cashes.

I considered it before and discarded at first since when an Org version 
having such file is loaded then old version is used in the case of 
messed version compilation. As a result, modification of 
`org-assert-version' is ignored in the compiled version.

I reconsidered my opinion, though I still can not get really robust 
problem detection. Emacs-27.1 and its built-in Org version is assumed below.

Since `org-assert-version' has effect in compiled files only, we need 
some file with minimal dependencies that certainly will be compiled. It 
might be org-assert-version.el itself. However then it be required 
always rather than wrapped into `eval-when-compile' and should have 
(org-assert-version) call inside.

> However, I am concerned about what is going to happen if wrong
> org-version is defined during compilation. `org-assert-version' can
> then be compiled with wrong org-version value and later produce similar
> obscure error.

If an old Org version is not loaded then the warning appears, so the 
assertion works. A couple of issues:
- it does not suggest messed version compilation (reinstalling or 
removing *.elc files and recompiling)
- due to long text just last paragraph about straight may be visible to 
the user. Perhaps it is better to expand 
https://orgmode.org/worg/org-faq.html#mixed-install and use a more 
concise message with this link.

I have tried the following:
- move `org-assert-version' definition to org-assert-version.el, add 
(org-assert-version) call to this file to have at least one file compiled.
- add (require 'org-assert-version) before (org-assert-version) to other 
files.

The warning appears unless built-in Org is loaded before adding new 
version to `load-path'. So we may proceed this way.

Some details concerning compilation errors in the case of Emacs-27.1 and 
Org main:

- org.el is compiled (to my surprise)
- most of libraries not loaded before compilation, e.g. all ox-*.el 
files fails.

The reason is that they require org-elemnt that requires org-persist. 
The latter fails to call `org-file-name-concat' (that is missed in 
loaded org-compat) and breaks creation of the .elc file.

Finally, there is a way to not have org-assert-version.el loaded during 
regular sessions. Most of elisp files should have

(eval-when-compile (require 'org-assert-version))
(org-assert-version)

It should ensure latest `org-assert-version' definition during 
installing of a new Org version. The issue is that compilation of 
arbitrary file may fail and I am unsure if it is reasonable to introduce 
another file to ensure compiled variant and to require it everywehere

(eval-when-compile (require 'org-assert-version))
(org-assert-version)
(require 'org-assert-version-call)

with org-assert-version-call.el

(eval-when-compile (require 'org-assert-version))
(org-assert-version)
(provide 'org-assert-version-call)



      reply	other threads:[~2023-01-04 11:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-18  5:20 Bug? org-assert-version does not prevent mixed install Max Nikulin
2022-12-18 13:04 ` Ihor Radchenko
2022-12-18 14:06   ` Max Nikulin
2022-12-18 14:26     ` Ihor Radchenko
2022-12-27 16:32       ` Max Nikulin
2022-12-28  9:46         ` Ihor Radchenko
2023-01-04 11:27           ` Max Nikulin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='tp3nq5$fsf$1@ciao.gmane.io' \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).