Some relevant settings that may be altered by your config are `ess-startup-directory` and `ess-startup-directory-function`. It might be, for example, that one of these is forcibly changing the R process' working directory to a project root ("~/Org", in this instance)

Yes, I found the reason `project-rootfile` changed the directory when babel source block execution.

By the way, setting `:dir` changes the *working* directory, which you might not want to be "images". There is a separate header argument, `:output-dir` that can be used for this purpose.

Thanks for your tips.


[stardiviner]           <Hack this world!>      GPG key ID: 47C32433
IRC(freeenode): stardiviner                     Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/


On Tue, Jan 14, 2025 at 6:49 PM <sam@crawf.uk> wrote:
On 2025-01-14 05:29, stardiviner wrote:

I tested using org-mode's `make repro` clean Emacs & org-mode environment instance. It works fine. I double checked my Emacs init file about R settings. Have not found suspicious config.

So to confirm, you *cannot* reproduce the error with a clean config?

Here is my reproduce test.

I tried running this, and it seems to work as expected.

The generated plot image "images/hist_rnorm.png" is NOT in
"~/Org/Programming/R/images/hist_rnorm.png". It's in "~/Org/hist_rnorm.png".

Some relevant settings that may be altered by your config are `ess-startup-directory` and `ess-startup-directory-function`. It might be, for example, that one of these is forcibly changing the R process' working directory to a project root ("~/Org", in this instance)

By the way, setting `:dir` changes the *working* directory, which you might not want to be "images". There is a separate header argument, `:output-dir` that can be used for this purpose.

Sam