Skip to content

Wrong behavior when :dir set #302

@akirakyle

Description

@akirakyle

When setting the :dir header argument, it looks like the path is being expanded twice.

For example the following block run in a file in /home/notebook

#+BEGIN_SRC jupyter-python :dir src
print("hi")
#+END_SRC

will result in the error

FileNotFoundErrorTraceback (most recent call last)
<ipython-input-1-1028f0c44f21> in <module>
      1 import os
      2 __JUPY_saved_dir = os.getcwd()
----> 3 os.chdir("/home/notebook/src/src")
      4 try:
      5     get_ipython().run_cell("""%load_ext autoreload

FileNotFoundError: [Errno 2] No such file or directory: '/home/notebook/src/src'

It appears this is due to org changing default-directory before org-babel-expand-body:jupyter is called so then (expand-file-name dir) is expanding again. As a patch I just replaced that call with default-directory and it works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions