Finally found the real reason: package `project-rootfile` -> (add-to-list 'project-find-functions #'project-rootfile-try-detect t) I don't know why project-rootfile involved in the Org mode Babel source block execution path. I checked out the source code of `project-rootfile`. Have not found any clue. Anyone have thoughts on this weird problem? [stardiviner] 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 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 >