all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [BUG] org-babel-load-file can not compile file
@ 2022-05-10  7:34 Max Nikulin
  2022-05-11 12:41 ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Max Nikulin @ 2022-05-10  7:34 UTC (permalink / raw)
  To: orgmode; +Cc: Stefan Kangas, Kyle Meyer

Consider the following file ex-ob-load-file.org:

---- >8 ----
#+begin_src emacs-lisp
   (defun ex-org-babel-load-file (msg)
     (message "From tagled file: %s" msg))
#+end_src

[[elisp:(org-babel-load-file "ex-ob-load-file.org" t)]]
---- 8< ----

Try to follow the link at the end of file or just execute the command in 
the link target.

Expected result: the .org file is tangled to ex-ob-load-file.el, the 
latter is compiled and loaded.

Actual result:
> Compiling /home/ubuntu/examples/org/ex-ob-load-file.el...done
> Wrote /home/ubuntu/examples/org/ex-ob-load-file.elc
> progn: Cannot open load file: No such file or directory, ex-ob-load-file.el

It seems, it is a regression caused by the Org commit 
0193b543e9ef84bfefe76d55e330d5b1cb842cef

> author Stefan Kangas <stefan@marxist.se> Tue Sep 22 00:16:22 2020 +0200
> committer Kyle Meyer <kyle@kyleam.com> Sun Oct 25 01:10:16 2020 -0400
> 
> Backport commit 4a575eb18 from Emacs
> 
> byte-compile-file: Make optional LOAD argument obsolete
> 4a575eb18cca3eed5019f2d2d2abeea1f0c07005
> Stefan Kangas
> Tue Oct 20 18:48:27 2020 +0200
> 
> diff --git a/lisp/org.el b/lisp/org.el
> index db7f83825..73b1f9458 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -232,7 +232,8 @@ byte-compiled before it is loaded."
>        (org-babel-tangle-file file tangled-file "emacs-lisp\\|elisp"))
>      (if compile
>  	(progn
> -	  (byte-compile-file tangled-file 'load)
> +	  (byte-compile-file tangled-file)
> +	  (load tangled-file)
>  	  (message "Compiled and loaded %s" tangled-file))
>        (load-file tangled-file)
>        (message "Loaded %s" tangled-file))))

It seems with the 'load argument `byte-compile-file' was able to load a 
file outside of `load-path'.

Emacs 26.3, Org main or bugfix branches.

Org-9.3.1 works fine.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] org-babel-load-file can not compile file
  2022-05-10  7:34 [BUG] org-babel-load-file can not compile file Max Nikulin
@ 2022-05-11 12:41 ` Ihor Radchenko
  2022-05-12 14:55   ` Max Nikulin
  0 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2022-05-11 12:41 UTC (permalink / raw)
  To: Max Nikulin; +Cc: orgmode, Stefan Kangas, Kyle Meyer

Max Nikulin <manikulin@gmail.com> writes:

> Actual result:
>> Compiling /home/ubuntu/examples/org/ex-ob-load-file.el...done
>> Wrote /home/ubuntu/examples/org/ex-ob-load-file.elc
>> progn: Cannot open load file: No such file or directory, ex-ob-load-file.el
>
> It seems, it is a regression caused by the Org commit 
> 0193b543e9ef84bfefe76d55e330d5b1cb842cef
>
>> -	  (byte-compile-file tangled-file 'load)
>> +	  (byte-compile-file tangled-file)
>> +	  (load tangled-file)


What if you substitute the load call with
(load (byte-compile-dest-file tangled-file))?

Best,
Ihor


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] org-babel-load-file can not compile file
  2022-05-11 12:41 ` Ihor Radchenko
@ 2022-05-12 14:55   ` Max Nikulin
  2022-05-13 10:38     ` Ihor Radchenko
  2022-05-13 10:38     ` Ihor Radchenko
  0 siblings, 2 replies; 8+ messages in thread
From: Max Nikulin @ 2022-05-12 14:55 UTC (permalink / raw)
  To: emacs-orgmode

On 11/05/2022 19:41, Ihor Radchenko wrote:
> Max Nikulin writes:
> 
>> Actual result:
>>> Compiling /home/ubuntu/examples/org/ex-ob-load-file.el...done
>>> Wrote /home/ubuntu/examples/org/ex-ob-load-file.elc
>>> progn: Cannot open load file: No such file or directory, ex-ob-load-file.el
>>
>> It seems, it is a regression caused by the Org commit
>> 0193b543e9ef84bfefe76d55e330d5b1cb842cef
>>
>>> -	  (byte-compile-file tangled-file 'load)
>>> +	  (byte-compile-file tangled-file)
>>> +	  (load tangled-file)
> 
> 
> What if you substitute the load call with
> (load (byte-compile-dest-file tangled-file))?

I do not mind (of course if there is no plan to deprecate the function).

In addition, from my point of view, `byte-recompile-file' with 0 as the 
FORCE argument is more suitable than simple `byte-compile-file' since 
the former does not rewrite the compiled file when it is up to date.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] org-babel-load-file can not compile file
  2022-05-12 14:55   ` Max Nikulin
@ 2022-05-13 10:38     ` Ihor Radchenko
  2022-05-13 10:38     ` Ihor Radchenko
  1 sibling, 0 replies; 8+ messages in thread
From: Ihor Radchenko @ 2022-05-13 10:38 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 468 bytes --]

Max Nikulin <manikulin@gmail.com> writes:

>> What if you substitute the load call with
>> (load (byte-compile-dest-file tangled-file))?
>
> I do not mind (of course if there is no plan to deprecate the function).
>
> In addition, from my point of view, `byte-recompile-file' with 0 as the 
> FORCE argument is more suitable than simple `byte-compile-file' since 
> the former does not rewrite the compiled file when it is up to date.

What about simply using touch?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-babel-load-file-Do-not-rely-on-org-babel-tangle-.patch --]
[-- Type: text/x-patch, Size: 1458 bytes --]

From 9746b9cd0a1accfc20b9d59c387bb05624154fe2 Mon Sep 17 00:00:00 2001
Message-Id: <9746b9cd0a1accfc20b9d59c387bb05624154fe2.1652438075.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Fri, 13 May 2022 18:21:36 +0800
Subject: [PATCH] org-babel-load-file: Do not rely on `org-babel-tangle-file'
 making changes

* lisp/org.el (org-babel-load-file): Update modification time even
when `org-babel-tangle-file' does not actually modify the tangled
file.  This makes sure that modify-time comparison logic does not make
Org re-tangle Org file that had been changed but the changes did not
affect the tangled code.

See https://orgmode.org/list/t5j75h$dbo$1@ciao.gmane.io
---
 lisp/org.el | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index 47a16e94b..09a001414 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -256,6 +256,11 @@ (defun org-babel-load-file (file &optional compile)
 	     tangled-file
 	     (file-attribute-modification-time
 	      (file-attributes (file-truename file))))
+      ;; Make sure that tangled file modification time is
+      ;; updated even when `org-babel-tangle-file' does not make changes.
+      ;; This avoids re-tangling changed FILE where the changes did
+      ;; not affect the tangled code.
+      (set-file-times tangled-file)
       (org-babel-tangle-file file
                              tangled-file
                              (rx string-start
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [BUG] org-babel-load-file can not compile file
  2022-05-12 14:55   ` Max Nikulin
  2022-05-13 10:38     ` Ihor Radchenko
@ 2022-05-13 10:38     ` Ihor Radchenko
  2022-05-14 10:36       ` Max Nikulin
  1 sibling, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2022-05-13 10:38 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

>>> It seems, it is a regression caused by the Org commit
>>> 0193b543e9ef84bfefe76d55e330d5b1cb842cef
>>>
>>>> -	  (byte-compile-file tangled-file 'load)
>>>> +	  (byte-compile-file tangled-file)
>>>> +	  (load tangled-file)
>> 
>> 
>> What if you substitute the load call with
>> (load (byte-compile-dest-file tangled-file))?
>
> I do not mind (of course if there is no plan to deprecate the function).

Fixed on bugfix via 4fe59b688

Best,
Ihor


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] org-babel-load-file can not compile file
  2022-05-13 10:38     ` Ihor Radchenko
@ 2022-05-14 10:36       ` Max Nikulin
  2022-05-14 11:35         ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Max Nikulin @ 2022-05-14 10:36 UTC (permalink / raw)
  To: emacs-orgmode

On 13/05/2022 17:38, Ihor Radchenko wrote:
> Max Nikulin writes:
> 
>>>> It seems, it is a regression caused by the Org commit
>>>> 0193b543e9ef84bfefe76d55e330d5b1cb842cef
>>>>
>>>>> -	  (byte-compile-file tangled-file 'load)
>>>>> +	  (byte-compile-file tangled-file)
>>>>> +	  (load tangled-file)
>>>
>>>
>>> What if you substitute the load call with
>>> (load (byte-compile-dest-file tangled-file))?
>>
>> I do not mind (of course if there is no plan to deprecate the function).
> 
> Fixed on bugfix via 4fe59b688

Ihor, I am sorry for confusion, it still does not work for me. Likely I 
tried locally with `load-file' instead of `load'. The former 
additionally has `expand-file-name'. (Emacs-26.3)

As to another patch

Date: Fri, 13 May 2022 18:21:36 +0800
Subject: [PATCH] org-babel-load-file: Do not rely on 
`org-babel-tangle-file' making changes

The following thread should be more suitable for discussion

Greg Minshall to emacs-orgmode. tangle option to not write a file with 
same contents? Thu, 28 Oct 2021 07:04:58 +0300. 
https://list.orgmode.org/583051.1635393898@apollo2.minshall.org



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] org-babel-load-file can not compile file
  2022-05-14 10:36       ` Max Nikulin
@ 2022-05-14 11:35         ` Ihor Radchenko
  2022-05-16 14:53           ` Max Nikulin
  0 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2022-05-14 11:35 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> On 13/05/2022 17:38, Ihor Radchenko wrote:
>> Max Nikulin writes:
>> 
>>>>> It seems, it is a regression caused by the Org commit
>>>>> 0193b543e9ef84bfefe76d55e330d5b1cb842cef
>>>>>
>>>>>> -	  (byte-compile-file tangled-file 'load)
>>>>>> +	  (byte-compile-file tangled-file)
>>>>>> +	  (load tangled-file)
>>>>
>>>>
>>>> What if you substitute the load call with
>>>> (load (byte-compile-dest-file tangled-file))?
>>>
>>> I do not mind (of course if there is no plan to deprecate the function).
>> 
>> Fixed on bugfix via 4fe59b688
>
> Ihor, I am sorry for confusion, it still does not work for me. Likely I 
> tried locally with `load-file' instead of `load'. The former 
> additionally has `expand-file-name'. (Emacs-26.3)

Should work now.

Best,
Ihor


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] org-babel-load-file can not compile file
  2022-05-14 11:35         ` Ihor Radchenko
@ 2022-05-16 14:53           ` Max Nikulin
  0 siblings, 0 replies; 8+ messages in thread
From: Max Nikulin @ 2022-05-16 14:53 UTC (permalink / raw)
  To: emacs-orgmode

On 14/05/2022 18:35, Ihor Radchenko wrote:
> Max Nikulin writes:
> 
>> Ihor, I am sorry for confusion, it still does not work for me. Likely I
>> tried locally with `load-file' instead of `load'. The former
>> additionally has `expand-file-name'. (Emacs-26.3)
> 
> Should work now.

Thank you, Ihor. I can confirm that my test example works now.



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-05-16 15:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-10  7:34 [BUG] org-babel-load-file can not compile file Max Nikulin
2022-05-11 12:41 ` Ihor Radchenko
2022-05-12 14:55   ` Max Nikulin
2022-05-13 10:38     ` Ihor Radchenko
2022-05-13 10:38     ` Ihor Radchenko
2022-05-14 10:36       ` Max Nikulin
2022-05-14 11:35         ` Ihor Radchenko
2022-05-16 14:53           ` Max Nikulin

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.