Remember to cover the basics, that is, what you expected to happen and what in fact did happen. You don't know how to make a good report? See https://orgmode.org/manual/Feedback.html#Feedback Your bug report will be posted to the Org mailing list. ------------------------------------------------------------------------ This is a simplified reproducer of the problem, as discovered by user @lyndhurst on SE Emacs. See https://emacs.stackexchange.com/questions/82261/set-org-babel-source-block-parameters-dynamically for more details. Starting with `emacs -Q', open the following file: --8<---------------cut here---------------start------------->8--- * Bug report example #+begin_src shell echo "foo" #+end_src * Code #+begin_src elisp :results raw (setq org-babel-default-header-args:shell '((:results . "file") (:file . "results.txt") (:output-dir . "a"))) #+end_src --8<---------------cut here---------------end--------------->8--- Evaluate the last code block to set `org-babel-default-header-args:shell' to the indicated value, then evaluate the shell code block repeatedly: the first time it works to produce an output file `a/results.txt'; subsequent evaluations produce errors: org-ctrl-c-ctrl-c: Opening output file: No such file or directory, .../a/a/results.txt org-ctrl-c-ctrl-c: Opening output file: No such file or directory, .../a/a/a/results.txt org-ctrl-c-ctrl-c: Opening output file: No such file or directory, .../a/a/a/a/results.txt Note the increasing number of copies of the `output-dir' setting. The value of `org-babel-default-header-args:shell' is modified every time: ((:results . "file") (:file . "a/a/a/a/results.txt") (:output-dir . "a")) The problem is the way that `org-babel-get-src-block-info' constructs the `info' variable, which is used to pass around information during the evaluation: the value depends on the `org-babel-default-header-args*' variables, but is modified in place, and because of shared list structure, the modification gets propagated to the user variables. Emacs : GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.0) of 2024-08-09 Package: Org mode version 9.8-pre (release_9.7.10-127-g07dd3b @/usr/local/share/emacs/site-lisp/org/) ------------------------------------------------------------------ The following patch wraps calls to `copy-tree' around the relevant places to eliminate the sharing.