emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jack Kamm <jackkamm@gmail.com>
To: Felipe Lema <felipelema@mortemale.org>, emacs-orgmode@gnu.org
Cc: Bastien <bzg@gnu.org>
Subject: Re: correct remote path handling
Date: Tue, 25 Feb 2020 07:54:28 -0800	[thread overview]
Message-ID: <8736ayy85n.fsf@gmail.com> (raw)
In-Reply-To: <1873694.uLqJpLN6Zz@linux-q1p8>

Hi Felipe,

Felipe Lema <felipelema@mortemale.org> writes:

> I bumped into a problem running src blocks using a remote (tramp) :dir. I've 
> looked into it and found that the problem is that a temporary file is passed 
> as a remote path to the remote process (temp file should be local to remote 
> process).

Thanks for finding this bug and submitting a patch to fix it.

> I'm attaching fixes for python and shell src blocks. I didn't add any tests 
> because that would require more than 15 LOC.

I think it would be difficult to test for this, so I wouldn't worry too
much about it, but if you have ideas for how to do it that'd be great.

> I've signed the necessary papers from (to?) the FSF involving org mode, so I'm 
> ready on my side to add tests and maybe add support for other tramp-related 
> stuff.

Great, we should add you to the list of copyrighted contributors:
https://orgmode.org/worg/org-contribute.html

CC'ing Bastien in case he wants to verify everything by private message
first.

>     fix evaluate python code in remote directory
>
>     Evaluating an "AST python code" should be local to the process /
>     directory.
>
>     `file-local-name` will do just this (strip the tramp prefix in path)

Please see https://orgmode.org/worg/org-contribute.html#commit-messages
for information on how to properly format commit messages. You can also
take a look at the git log for examples.

> -				   tmp-src-file))))
> +				   (file-local-name
> +				    tmp-src-file)))))

Instead of `file-local-name', the preferred function we use for this is
`org-babel-process-file-name'. It's used in a few other places in
ob-python.el as well.

It looks like this patch only handles the ":session :results value"
case, but ":session :results output" also suffers from this problem,
could you add a fix for that case as well?

For example, I tried to execute the following ":session :results output"
block within a remote Org file, with the following result:

#+begin_src python :session :results output
  x = 1+1
  x
#+end_src

#+RESULTS:
: Traceback (most recent call last):
:   File "<stdin>", line 1, in <module>
: IOError: [Errno 2] No such file or directory: '/scp:pi:/tmp/python-NJwf2U'


> -			   (format "%s %s" shell-file-name script-file))
> +			   (format "%s %s" shell-file-name
> +				   (file-local-name script-file)))

As noted above, use `org-babel-process-file-name' instead of
`file-local-name'.

Also, I'm not sure the shell case is totally fixed by this, for example
trying to execute the following shell block within a remote Org file
still yields the error, even after applying your patch:

#+begin_src shell :shebang "#!/usr/bin/bash"
  echo foo
#+end_src

/bin/sh: 1: /scp:pi:/tmp/sh-script-8Z5fw7: not found

  reply	other threads:[~2020-02-25 15:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-25  1:36 correct remote path handling Felipe Lema
2020-02-25 15:54 ` Jack Kamm [this message]
2020-02-25 19:14   ` Bastien
2020-02-27  1:58     ` Felipe Lema
2020-02-29 16:22       ` Jack Kamm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8736ayy85n.fsf@gmail.com \
    --to=jackkamm@gmail.com \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=felipelema@mortemale.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).