I've tracked the issue down, but not sure about the best way to fix it. I've attached a patch but worry that it might have unintended side effects.
This only affects :file when it is set on a src block. If :file is provided via properties there is no problem. The call stack is org-ctrl-c-ctrl-c org-babel-lob-get-info ; in section for babel-call org-babel-lob--src-info org-babel-get-src-block-info The call to org-babel-get-src-block-info inside org-babel-lob--src-info is made with no-eval t. The fix that makes the most sense to me is to make org-babel-lob--src-info no-eval aware, but I'm not sure that calls to org-babel-lob-get-info are passed no-eval in a way that is safe, because the default behavior is inverted and there are no calls to org-babel-lob-get-info that actually set no-eval as far as I can tell.
From 146ae5de2c4881fa938b005955f45244ce92f6f0 Mon Sep 17 00:00:00 2001 From: Tom Gillespie <tgbugs@gmail.com> Date: Mon, 21 Apr 2025 14:28:19 -0700 Subject: [PATCH] ob-lob: Fix babel-call not correctly evaluating :file elisp * lisp/ob-lob (org-babel-lob--src-info): Handle no-eval case. This fixes a bug where running a #+call: for a src block that sets the :file header using an elisp expression would use the un-evaluated expression as the file name instead of the result. --- lisp/ob-lob.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/ob-lob.el b/lisp/ob-lob.el index 472f9eda1..575e0dc09 100644 --- a/lisp/ob-lob.el +++ b/lisp/ob-lob.el @@ -86,7 +86,7 @@ if so then run the appropriate source block from the Library." (org-babel-execute-src-block nil info nil (org-element-type datum)) t))) -(defun org-babel-lob--src-info (ref) +(defun org-babel-lob--src-info (ref no-eval) "Return internal representation for Babel data referenced as REF. REF is a string. This function looks into the current document for a Babel call or source block. If none is found, it looks @@ -112,7 +112,7 @@ after REF in the Library of Babel." (when (equal name (org-element-property :name element)) (throw :found (pcase (org-element-type element) - (`src-block (org-babel-get-src-block-info t element)) + (`src-block (org-babel-get-src-block-info no-eval element)) (`babel-call (org-babel-lob-get-info element)) ;; Non-executable data found. Since names ;; are supposed to be unique throughout @@ -138,7 +138,7 @@ see." (type (org-element-type context)) (reference (org-element-property :call context))) (when (memq type '(babel-call inline-babel-call)) - (pcase (org-babel-lob--src-info reference) + (pcase (org-babel-lob--src-info reference no-eval) (`(,language ,body ,header ,_ ,_ ,_ ,coderef) (let ((begin (org-element-property (if (eq type 'inline-babel-call) :begin -- 2.49.0