The manual says :dir is working directory and :output-dir is output directory. It is a a bit confusing. If I don't set output dir, shouldn't it generate output files in the working directory?

For example, this works as expected, outputting the figure in :dir:

#+begin_src ditaa :file demo-ditaa-simpleboxes.png :dir /tmp/
  |         |
  | Foo     |
  |         |
  |Bar |Baz     |
  |    |        |


However, in the following example, if I only specify :dir but not :output-dir, the plot will be saved in the dir of the buffer, not :dir.

#+begin_src R :results file graphics replace :file demo-r-plot.png :dir ~/work-dir 

And for the following example, the foo/foo.png isn't created; however, if I delete DIR property and let it create attach dir from the ID, foo.png is created successfully in the attach dir... It seems :output-dir is buggy?

:ID:       20230727T095322.203310
:DIR:      foo
#+title: abc
#+property: header-args+ :output-dir (org-attach-dir-get-create)

#+begin_src R :results file  graphics :file foo.png


by the way, if I set :output-dir to some existing relative path like ../foo/spam, it fails to create foo.png too.

My emacs/org version is :

Org mode version 9.6.6 (release_9.6.6 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)
GNU Emacs 29.0.92 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G9323)) of 2023-06-18
  • What version of Org mode are you running? I run more-or-less latest upstream (Org mode version 9.7-pre (release_9.6.7-566-gdbb391)) and both code block produce their output where :output-dir says they should.
    – NickD
    Jul 26, 2023 at 15:10
  • I updated the question and clarified version.
    – RNA
    Jul 27, 2023 at 2:11
  • The versions are recent enough, but I cannot reproduce the problems you are describing: the first three work for me (assuming that ~/work-dir in the second case and ./foo in the third case exist as writable directories already). There are three directories of interest: the directory where the Org mode file lives (in my case, that's /tmp' in all cases), the :dir` directory which becomes the current working directory of the script in the code block and the :output-dir which is to be specified relative to the :dir directory....
    – NickD
    Jul 27, 2023 at 4:25
  • If the :dir directory is not specified then the directory where the Org mode file lives is the :dir directory. I have not tried the "by the way..." fourth case because I don't know what settings you have. Can you go back and specify the directory of the Org mode file in all cases? And in the last case, provide a complete example that I can cut and paste to try out?
    – NickD
    Jul 27, 2023 at 4:28


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.