Jeremie Juste <jeremieju...@gmail.com> writes: > Note also that you can force the R process to start in a particular > directory with the dir parameter. > > #+begin_src R :dir ~/ > getwd() > #+end_src > > #+RESULTS: > : /home/djj > > > Now on the org-mode side. This is becomes tricky because I don't know > what users expects. For now this issue is delegated to the ESS configuration. > Is the present state a satisfactory one? Please voice out your opinion.
>From Org perspective, we should follow what :dir does and fallback to buffer's `default-directory' otherwise: 16.4 Environment of a Code Block The ‘dir’ header argument specifies the default directory during code block execution. If it is absent, then the directory associated with the current buffer is used. In other words, supplying ‘:dir DIRECTORY’ temporarily has the same effect as changing the current directory with ‘M-x cd <RET> DIRECTORY’, and then not setting ‘dir’. Under the surface, ‘dir’ simply sets the value of the Emacs variable ‘default-directory’. Setting ‘mkdirp’ header argument to a non-‘nil’ value creates the directory, if necessary. For example, to save the plot file in the ‘Work/’ folder of the home directory—notice tilde is expanded: #+BEGIN_SRC R :file myplot.png :dir ~/Work matplot(matrix(rnorm(100), 10), type="l") #+END_SRC So, if R has some way to override the working directory, we should enforce what we promise in the above section of our manual anyway. Otherwise, the will lose on Org document reproducibility. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>