From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jack Kamm Subject: Re: correct remote path handling Date: Tue, 25 Feb 2020 07:54:28 -0800 Message-ID: <8736ayy85n.fsf@gmail.com> References: <1873694.uLqJpLN6Zz@linux-q1p8> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:36208) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6cYh-000685-9c for emacs-orgmode@gnu.org; Tue, 25 Feb 2020 10:55:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6cYg-0007c6-3r for emacs-orgmode@gnu.org; Tue, 25 Feb 2020 10:55:43 -0500 In-Reply-To: <1873694.uLqJpLN6Zz@linux-q1p8> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Sender: "Emacs-orgmode" To: Felipe Lema , emacs-orgmode@gnu.org Cc: Bastien Hi Felipe, Felipe Lema 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 "", line 1, in : 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