emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org mode R remote code evaluation
@ 2013-08-29  6:31 Johannes Rainer
  2013-08-29  8:25 ` Loris Bennett
  0 siblings, 1 reply; 18+ messages in thread
From: Johannes Rainer @ 2013-08-29  6:31 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1512 bytes --]

dear all,

I have some computation intense R-code that I want to run remotely on my
server, and, according to the org manual that should be possible with the
":dir" parameter. so I went on and tried the following (user/server masked):

#+BEGIN_SRC R :dir /xx@xxx:
  system("hostname")
#+END_SRC

when I execute it I get the error:

Tramp: Encoding region using function `base64-encode-region'...done
Tramp: Decoding region into remote file /ssh:xx@xxx
:/var/folders/ny/6kbb36310wz2kww8y8ctry600000gn/T/R-46345BQs...done
byte-code: Couldn't write region to
`/ssh:xx@xxx:/var/folders/ny/6kbb36310wz2kww8y8ctry600000gn/T/R-46345BQs',
decode using `base64 -d -i >%s' failed

apparently, this temp folder does not exist on the linux server, it is
actually the temp folder from my local machine.

I get the same error when I try to execute remote shell code, so it's not R
related.

I also tried to start a ssh session using "M-x ssh" and used the source
block

#+BEGIN_SRC R :exports both :session *ssh xxx*
system("hostname")
#+END_SRC

on the server it executes the command but it can not write the results:

> xxx
> Warning message:
In file.rename(tfile, transfer.file) :
  cannot rename file '/tmp/RtmpsirjGl/file51c8f6ce4ec' to
'/var/folders/ny/6kbb36310wz2kww8y8ctry600000gn/T/babel-46345zSH/R-46345a4N',
reason 'No such file or directory'
>

I am using emacs 24.3 and Org-mode version 8.0.7 (release_8.0.7-384-g6fdc23)

I would be helpful for any suggestions how I could solve this problem.

thanks in advance

[-- Attachment #2: Type: text/html, Size: 1922 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-08-29  6:31 org mode R remote code evaluation Johannes Rainer
@ 2013-08-29  8:25 ` Loris Bennett
  2013-08-29 10:42   ` Johannes Rainer
  0 siblings, 1 reply; 18+ messages in thread
From: Loris Bennett @ 2013-08-29  8:25 UTC (permalink / raw)
  To: emacs-orgmode

Johannes Rainer <johannes.rainer@gmail.com> writes:

> dear all,
>
> I have some computation intense R-code that I want to run remotely on my server,
> and, according to the org manual that should be possible with the ":dir"
> parameter. so I went on and tried the following (user/server masked):
>
> #+BEGIN_SRC R :dir /xx@xxx:
>   system("hostname")
> #+END_SRC
>
> when I execute it I get the error:
>
> Tramp: Encoding region using function `base64-encode-region'...done
> Tramp: Decoding region into remote file
> /ssh:xx@xxx:/var/folders/ny/6kbb36310wz2kww8y8ctry600000gn/T/R-46345BQs...done
> byte-code: Couldn't write region to
> `/ssh:xx@xxx:/var/folders/ny/6kbb36310wz2kww8y8ctry600000gn/T/R-46345BQs',
> decode using `base64 -d -i >%s' failed
>
> apparently, this temp folder does not exist on the linux server, it is actually
> the temp folder from my local machine.
>
> I get the same error when I try to execute remote shell code, so it's not R
> related.
>
> I also tried to start a ssh session using "M-x ssh" and used the source block
>
> #+BEGIN_SRC R :exports both :session *ssh xxx*
> system("hostname")
> #+END_SRC
>
> on the server it executes the command but it can not write the results:
>
>> xxx
>> Warning message:
> In file.rename(tfile, transfer.file) :
>   cannot rename file '/tmp/RtmpsirjGl/file51c8f6ce4ec' to
> '/var/folders/ny/6kbb36310wz2kww8y8ctry600000gn/T/babel-46345zSH/R-46345a4N',
> reason 'No such file or directory'
>>
>
> I am using emacs 24.3 and Org-mode version 8.0.7 (release_8.0.7-384-g6fdc23)
>
> I would be helpful for any suggestions how I could solve this problem.
>
> thanks in advance

The following works for me:

#+BEGIN_SRC R :results output :dir /xxx@xxxxx:
system("hostname")
#+END_SRC

with Emacs 24.2.1 and 8.0.7 (8.0.7-6-g13cb28-elpaplus)

Cheers,

Loris

-- 
This signature is currently under construction.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-08-29  8:25 ` Loris Bennett
@ 2013-08-29 10:42   ` Johannes Rainer
  2013-09-23 16:45     ` Alexander Vorobiev
  0 siblings, 1 reply; 18+ messages in thread
From: Johannes Rainer @ 2013-08-29 10:42 UTC (permalink / raw)
  To: Loris Bennett; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2540 bytes --]

thanks! so the ":results output" does the trick.




On Thu, Aug 29, 2013 at 10:25 AM, Loris Bennett
<loris.bennett@fu-berlin.de>wrote:

> Johannes Rainer <johannes.rainer@gmail.com> writes:
>
> > dear all,
> >
> > I have some computation intense R-code that I want to run remotely on my
> server,
> > and, according to the org manual that should be possible with the ":dir"
> > parameter. so I went on and tried the following (user/server masked):
> >
> > #+BEGIN_SRC R :dir /xx@xxx:
> >   system("hostname")
> > #+END_SRC
> >
> > when I execute it I get the error:
> >
> > Tramp: Encoding region using function `base64-encode-region'...done
> > Tramp: Decoding region into remote file
> > /ssh:xx@xxx
> :/var/folders/ny/6kbb36310wz2kww8y8ctry600000gn/T/R-46345BQs...done
> > byte-code: Couldn't write region to
> > `/ssh:xx@xxx
> :/var/folders/ny/6kbb36310wz2kww8y8ctry600000gn/T/R-46345BQs',
> > decode using `base64 -d -i >%s' failed
> >
> > apparently, this temp folder does not exist on the linux server, it is
> actually
> > the temp folder from my local machine.
> >
> > I get the same error when I try to execute remote shell code, so it's
> not R
> > related.
> >
> > I also tried to start a ssh session using "M-x ssh" and used the source
> block
> >
> > #+BEGIN_SRC R :exports both :session *ssh xxx*
> > system("hostname")
> > #+END_SRC
> >
> > on the server it executes the command but it can not write the results:
> >
> >> xxx
> >> Warning message:
> > In file.rename(tfile, transfer.file) :
> >   cannot rename file '/tmp/RtmpsirjGl/file51c8f6ce4ec' to
> >
> '/var/folders/ny/6kbb36310wz2kww8y8ctry600000gn/T/babel-46345zSH/R-46345a4N',
> > reason 'No such file or directory'
> >>
> >
> > I am using emacs 24.3 and Org-mode version 8.0.7
> (release_8.0.7-384-g6fdc23)
> >
> > I would be helpful for any suggestions how I could solve this problem.
> >
> > thanks in advance
>
> The following works for me:
>
> #+BEGIN_SRC R :results output :dir /xxx@xxxxx:
> system("hostname")
> #+END_SRC
>
> with Emacs 24.2.1 and 8.0.7 (8.0.7-6-g13cb28-elpaplus)
>
> Cheers,
>
> Loris
>
> --
> This signature is currently under construction.
>
>
>


-- 
Johannes Rainer, PhD
Applied Bioinformatics Group,
Division Molecular Pathophysiology,
Biocenter, Medical University Innsbruck,
Innrain 80/82 II, 6020 Innsbruck, Austria
and
Tyrolean Cancer Research Institute
Innrain 66, 6020 Innsbruck, Austria

Tel.:     +43 (0)512 9003 70961
Email:  johannes.rainer@i-med.ac.at
            johannes.rainer@tcri.at
URL:   http://bioinfo.i-med.ac.at

[-- Attachment #2: Type: text/html, Size: 3734 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-08-29 10:42   ` Johannes Rainer
@ 2013-09-23 16:45     ` Alexander Vorobiev
  2013-09-24 12:57       ` Michael Albinus
  0 siblings, 1 reply; 18+ messages in thread
From: Alexander Vorobiev @ 2013-09-23 16:45 UTC (permalink / raw)
  To: Johannes Rainer; +Cc: Loris Bennett, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3468 bytes --]

The ":results output" doesn't help in my setup (I'm on Windows, the remote
system is linux, access is via putty/plink)

#+BEGIN_SRC sh :results output :dir /grid:
  ls
#+END_SRC

executing Sh code block...
Tramp: Encoding region using function `base64-encode-region'...done
Tramp: Decoding region into remote file
/plinkx:grid:/Users/avorobi/AppData/Local/Temp/ob-input-6116fuY...done
byte-code: Couldn't write region to
`/plinkx:grid:/Users/avorobi/AppData/Local/Temp/ob-input-6116fuY', decode
using `tramp_perl_decode_with_module >%s' failed

The /Users directory obviously does not exist on linux.

Tramp itself works in my configuration, I can open files, etc. I have the
latest org-mode from elpa.

Thanks,
Alex


On Thu, Aug 29, 2013 at 5:42 AM, Johannes Rainer <
johannes.rainer@i-med.ac.at> wrote:

> thanks! so the ":results output" does the trick.
>
>
>
>
> On Thu, Aug 29, 2013 at 10:25 AM, Loris Bennett <
> loris.bennett@fu-berlin.de> wrote:
>
>> Johannes Rainer <johannes.rainer@gmail.com> writes:
>>
>> > dear all,
>> >
>> > I have some computation intense R-code that I want to run remotely on
>> my server,
>> > and, according to the org manual that should be possible with the ":dir"
>> > parameter. so I went on and tried the following (user/server masked):
>> >
>> > #+BEGIN_SRC R :dir /xx@xxx:
>> >   system("hostname")
>> > #+END_SRC
>> >
>> > when I execute it I get the error:
>> >
>> > Tramp: Encoding region using function `base64-encode-region'...done
>> > Tramp: Decoding region into remote file
>> > /ssh:xx@xxx
>> :/var/folders/ny/6kbb36310wz2kww8y8ctry600000gn/T/R-46345BQs...done
>> > byte-code: Couldn't write region to
>> > `/ssh:xx@xxx
>> :/var/folders/ny/6kbb36310wz2kww8y8ctry600000gn/T/R-46345BQs',
>> > decode using `base64 -d -i >%s' failed
>> >
>> > apparently, this temp folder does not exist on the linux server, it is
>> actually
>> > the temp folder from my local machine.
>> >
>> > I get the same error when I try to execute remote shell code, so it's
>> not R
>> > related.
>> >
>> > I also tried to start a ssh session using "M-x ssh" and used the source
>> block
>> >
>> > #+BEGIN_SRC R :exports both :session *ssh xxx*
>> > system("hostname")
>> > #+END_SRC
>> >
>> > on the server it executes the command but it can not write the results:
>> >
>> >> xxx
>> >> Warning message:
>> > In file.rename(tfile, transfer.file) :
>> >   cannot rename file '/tmp/RtmpsirjGl/file51c8f6ce4ec' to
>> >
>> '/var/folders/ny/6kbb36310wz2kww8y8ctry600000gn/T/babel-46345zSH/R-46345a4N',
>> > reason 'No such file or directory'
>> >>
>> >
>> > I am using emacs 24.3 and Org-mode version 8.0.7
>> (release_8.0.7-384-g6fdc23)
>> >
>> > I would be helpful for any suggestions how I could solve this problem.
>> >
>> > thanks in advance
>>
>> The following works for me:
>>
>> #+BEGIN_SRC R :results output :dir /xxx@xxxxx:
>> system("hostname")
>> #+END_SRC
>>
>> with Emacs 24.2.1 and 8.0.7 (8.0.7-6-g13cb28-elpaplus)
>>
>> Cheers,
>>
>> Loris
>>
>> --
>> This signature is currently under construction.
>>
>>
>>
>
>
> --
> Johannes Rainer, PhD
> Applied Bioinformatics Group,
> Division Molecular Pathophysiology,
> Biocenter, Medical University Innsbruck,
> Innrain 80/82 II, 6020 Innsbruck, Austria
> and
> Tyrolean Cancer Research Institute
> Innrain 66, 6020 Innsbruck, Austria
>
> Tel.:     +43 (0)512 9003 70961
> Email:  johannes.rainer@i-med.ac.at
>             johannes.rainer@tcri.at
> URL:   http://bioinfo.i-med.ac.at
>
>
>

[-- Attachment #2: Type: text/html, Size: 5220 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-09-23 16:45     ` Alexander Vorobiev
@ 2013-09-24 12:57       ` Michael Albinus
  2013-09-24 13:21         ` Alexander Vorobiev
  0 siblings, 1 reply; 18+ messages in thread
From: Michael Albinus @ 2013-09-24 12:57 UTC (permalink / raw)
  To: Alexander Vorobiev; +Cc: Loris Bennett, emacs-orgmode, Johannes Rainer

Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:

> The ":results output" doesn't help in my setup (I'm on Windows, the
> remote system is linux, access is via putty/plink)

I do not run Windows, so I cannot reproduce exactly. However, ...

> #+BEGIN_SRC sh :results output :dir /grid:
> ls
> #+END_SRC
>
> executing Sh code block...
> Tramp: Encoding region using function `base64-encode-region'...done
> Tramp: Decoding region into remote file
> /plinkx:grid:/Users/avorobi/AppData/Local/Temp/ob-input-6116fuY...done
> byte-code: Couldn't write region to
> `/plinkx:grid:/Users/avorobi/AppData/Local/Temp/ob-input-6116fuY',
> decode using `tramp_perl_decode_with_module >%s' failed
>
> The /Users directory obviously does not exist on linux.

... this looks like an old problem. Which Emacs/Tramp version are you using?
Check variables `emacs-version' and `tramp-version'.

> Thanks,
> Alex

Best regards, Michael.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-09-24 12:57       ` Michael Albinus
@ 2013-09-24 13:21         ` Alexander Vorobiev
  2013-09-24 13:25           ` Michael Albinus
  0 siblings, 1 reply; 18+ messages in thread
From: Alexander Vorobiev @ 2013-09-24 13:21 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Loris Bennett, emacs-orgmode, Johannes Rainer

[-- Attachment #1: Type: text/plain, Size: 1183 bytes --]

Here is what I have:

ELISP> emacs-version
"24.3.1"
ELISP> tramp-version
"2.2.7"
ELISP> org-version
"8.2"

Thanks,
Alex


On Tue, Sep 24, 2013 at 7:57 AM, Michael Albinus <michael.albinus@gmx.de>wrote:

> Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:
>
> > The ":results output" doesn't help in my setup (I'm on Windows, the
> > remote system is linux, access is via putty/plink)
>
> I do not run Windows, so I cannot reproduce exactly. However, ...
>
> > #+BEGIN_SRC sh :results output :dir /grid:
> > ls
> > #+END_SRC
> >
> > executing Sh code block...
> > Tramp: Encoding region using function `base64-encode-region'...done
> > Tramp: Decoding region into remote file
> > /plinkx:grid:/Users/avorobi/AppData/Local/Temp/ob-input-6116fuY...done
> > byte-code: Couldn't write region to
> > `/plinkx:grid:/Users/avorobi/AppData/Local/Temp/ob-input-6116fuY',
> > decode using `tramp_perl_decode_with_module >%s' failed
> >
> > The /Users directory obviously does not exist on linux.
>
> ... this looks like an old problem. Which Emacs/Tramp version are you
> using?
> Check variables `emacs-version' and `tramp-version'.
>
> > Thanks,
> > Alex
>
> Best regards, Michael.
>

[-- Attachment #2: Type: text/html, Size: 1947 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-09-24 13:21         ` Alexander Vorobiev
@ 2013-09-24 13:25           ` Michael Albinus
       [not found]             ` <CAGOCFPUyTaQzVTSwjUOJBfwF8vUzyw=Gn43+bHs8Go8+RUU+nA@mail.gmail.com>
  0 siblings, 1 reply; 18+ messages in thread
From: Michael Albinus @ 2013-09-24 13:25 UTC (permalink / raw)
  To: Alexander Vorobiev; +Cc: Loris Bennett, emacs-orgmode, Johannes Rainer

Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:

> Here is what I have:
>
> ELISP> emacs-version
> "24.3.1"
> ELISP> tramp-version
> "2.2.7"
> ELISP> org-version
> "8.2"

Well, that sounds recent. Could you, please, perform (setq tramp-verbose 6)
prior your test? There will be a Tramp debug buffer, which I would like
to analyze.

> Thanks,
> Alex

Best regards, Michael.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
       [not found]             ` <CAGOCFPUyTaQzVTSwjUOJBfwF8vUzyw=Gn43+bHs8Go8+RUU+nA@mail.gmail.com>
@ 2013-09-24 18:40               ` Michael Albinus
  2013-09-25  4:24                 ` Alexander Vorobiev
  0 siblings, 1 reply; 18+ messages in thread
From: Michael Albinus @ 2013-09-24 18:40 UTC (permalink / raw)
  To: Alexander Vorobiev; +Cc: Loris Bennett, emacs-orgmode, Johannes Rainer

Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:

> Hi Michael,

Hi Alex,

> Here it is.

Thanks. I believe, the following patch shall cure it:

--8<---------------cut here---------------start------------->8---
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2735,8 +2735,12 @@
 value of `temporary-file-directory' temporarily set to the value
 of `org-babel-temporary-directory'."
   (if (file-remote-p default-directory)
       (let ((prefix
+            ;; We cannot use `temporary-file-directory' as local part
+            ;; on the remote host, because it might be another OS
+            ;; there.  So we assume "/tmp", which ought to exist on
+            ;; relevant architectures.
              (concat (file-remote-p default-directory)
-                     (expand-file-name prefix temporary-file-directory))))
+                     (expand-file-name prefix "/tmp/"))))
         (make-temp-file prefix nil suffix))
     (let ((temporary-file-directory
           (or (and (boundp 'org-babel-temporary-directory)
--8<---------------cut here---------------end--------------->8---

Could you, please, test?

> Thanks,
> Alex

Best regards, Michael.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-09-24 18:40               ` Michael Albinus
@ 2013-09-25  4:24                 ` Alexander Vorobiev
  2013-09-25 10:44                   ` Michael Albinus
  0 siblings, 1 reply; 18+ messages in thread
From: Alexander Vorobiev @ 2013-09-25  4:24 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Loris Bennett, emacs-orgmode, Johannes Rainer

[-- Attachment #1: Type: text/plain, Size: 1667 bytes --]

Hi Michael,

The patch seems to be working, the only thing I noticed is having
http://www.emacswiki.org/emacs/setup-cygwin.el loaded together with the
patched ob-core.el makes tramp prepend "/cygwin" to /tmp/. When I disabled
(require 'setup-cygwin) the patch works as expected. Outside of org/babel
setup-cygwin has no effect on Tramp.

Thanks,
Alex


On Tue, Sep 24, 2013 at 1:40 PM, Michael Albinus <michael.albinus@gmx.de>wrote:

> Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:
>
> > Hi Michael,
>
> Hi Alex,
>
> > Here it is.
>
> Thanks. I believe, the following patch shall cure it:
>
> --8<---------------cut here---------------start------------->8---
> --- a/lisp/ob-core.el
> +++ b/lisp/ob-core.el
> @@ -2735,8 +2735,12 @@
>  value of `temporary-file-directory' temporarily set to the value
>  of `org-babel-temporary-directory'."
>    (if (file-remote-p default-directory)
>        (let ((prefix
> +            ;; We cannot use `temporary-file-directory' as local part
> +            ;; on the remote host, because it might be another OS
> +            ;; there.  So we assume "/tmp", which ought to exist on
> +            ;; relevant architectures.
>               (concat (file-remote-p default-directory)
> -                     (expand-file-name prefix temporary-file-directory))))
> +                     (expand-file-name prefix "/tmp/"))))
>          (make-temp-file prefix nil suffix))
>      (let ((temporary-file-directory
>            (or (and (boundp 'org-babel-temporary-directory)
> --8<---------------cut here---------------end--------------->8---
>
> Could you, please, test?
>
> > Thanks,
> > Alex
>
> Best regards, Michael.
>

[-- Attachment #2: Type: text/html, Size: 2418 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-09-25  4:24                 ` Alexander Vorobiev
@ 2013-09-25 10:44                   ` Michael Albinus
  2013-09-25 18:15                     ` Eric Schulte
  0 siblings, 1 reply; 18+ messages in thread
From: Michael Albinus @ 2013-09-25 10:44 UTC (permalink / raw)
  To: Alexander Vorobiev; +Cc: Loris Bennett, emacs-orgmode, Johannes Rainer

Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:

> Hi Michael,

Hi Alex,

> The patch seems to be working, the only thing I noticed is having
> http://www.emacswiki.org/emacs/setup-cygwin.el loaded together with
> the patched ob-core.el makes tramp prepend "/cygwin" to /tmp/. When I
> disabled (require 'setup-cygwin) the patch works as expected. Outside
> of org/babel setup-cygwin has no effect on Tramp.

This problem does not seem to be related to org-mode code. Could
somebody, please, commit my patch to org's repository? Thanks.

I will try to find out what's up with Tramp and Cygwin. Sadly, it has
been a misalliance very often :-(

> Thanks,
> Alex

Best regards, Michael.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-09-25 10:44                   ` Michael Albinus
@ 2013-09-25 18:15                     ` Eric Schulte
  2013-09-25 19:03                       ` Michael Albinus
  2013-09-27 11:39                       ` Michael Albinus
  0 siblings, 2 replies; 18+ messages in thread
From: Eric Schulte @ 2013-09-25 18:15 UTC (permalink / raw)
  To: Michael Albinus
  Cc: Loris Bennett, emacs-orgmode, Alexander Vorobiev, Johannes Rainer

Michael Albinus <michael.albinus@gmx.de> writes:

> Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:
>
>> Hi Michael,
>
> Hi Alex,
>
>> The patch seems to be working, the only thing I noticed is having
>> http://www.emacswiki.org/emacs/setup-cygwin.el loaded together with
>> the patched ob-core.el makes tramp prepend "/cygwin" to /tmp/. When I
>> disabled (require 'setup-cygwin) the patch works as expected. Outside
>> of org/babel setup-cygwin has no effect on Tramp.
>
> This problem does not seem to be related to org-mode code. Could
> somebody, please, commit my patch to org's repository? Thanks.
>

I'd rather not hard-code the value of "/tmp/".  Perhaps you could rework
the patch so that it introduces a new customizable variable (including a
documentation string) so that users can set the value for their system.

If you can keep the patch under 15LOC we can include it w/o requiring
FSF copyright assignment, otherwise see [1] for contribution details.
Also, please package the patch with git format-patch.

Thanks,

>
> I will try to find out what's up with Tramp and Cygwin. Sadly, it has
> been a misalliance very often :-(
>
>> Thanks,
>> Alex
>
> Best regards, Michael.
>


Footnotes: 
[1]   http://orgmode.org/worg/org-contribute.html

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-09-25 18:15                     ` Eric Schulte
@ 2013-09-25 19:03                       ` Michael Albinus
  2013-09-25 20:36                         ` Alexander Vorobiev
  2013-09-27 11:39                       ` Michael Albinus
  1 sibling, 1 reply; 18+ messages in thread
From: Michael Albinus @ 2013-09-25 19:03 UTC (permalink / raw)
  To: Eric Schulte
  Cc: Loris Bennett, emacs-orgmode, Alexander Vorobiev, Johannes Rainer

Eric Schulte <schulte.eric@gmail.com> writes:

> I'd rather not hard-code the value of "/tmp/".  Perhaps you could rework
> the patch so that it introduces a new customizable variable (including a
> documentation string) so that users can set the value for their system.

Will do, tomorrow. I would even prefer a more general solution, a new
function which returns a ("the") temp directory on a remote host. This
would be useful also outside org-mode. But this would require changes in
Emacs/Tramp, which won't be applicable for org immediately (backwards
compatibility, and alike).

> If you can keep the patch under 15LOC we can include it w/o requiring
> FSF copyright assignment, otherwise see [1] for contribution details.

No problem. As Tramp maintainer, I have signed the FSF papers for Emacs
10+ years ago. This shall be valid also for org patches.

> Thanks,

Best regards, Michael.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-09-25 19:03                       ` Michael Albinus
@ 2013-09-25 20:36                         ` Alexander Vorobiev
  2013-09-26  8:11                           ` Michael Albinus
  0 siblings, 1 reply; 18+ messages in thread
From: Alexander Vorobiev @ 2013-09-25 20:36 UTC (permalink / raw)
  To: Michael Albinus
  Cc: Loris Bennett, emacs-orgmode, Johannes Rainer, Eric Schulte

[-- Attachment #1: Type: text/plain, Size: 3071 bytes --]

Michael,

I found that the patch doesn't work for sql code blocks. Here is an example

* this works
#+BEGIN_SRC sh :results output :dir /grid:
  ls
#+END_SRC

* this doesn't work
#+BEGIN_SRC sql :engine postgresql :dir /grid: :results output
  select 1+2 as three;
#+END_SRC

and here is what appears in *Messages*:

executing Sh code block...
Tramp: Encoding region using function `base64-encode-region'...done
Tramp: Decoding region into remote file
/plinkx:grid:/tmp/ob-input-7928Z4Q...done
Tramp: Encoding region using function `base64-encode-region'...done
Tramp: Decoding region into remote file
/plinkx:grid:/tmp/ob-error-7928zMd...done
Tramp: Encoding region using function `base64-encode-region'...done
Tramp: Decoding region into remote file
/plinkx:grid:/tmp/ob-input-7928Z4Q...done
Wrote /plinkx:grid:/tmp/ob-input-7928Z4Q
Code block evaluation complete.
executing Sql code block...
Tramp: Encoding region using function `base64-encode-region'...done
Tramp: Decoding region into remote file
/plinkx:grid:/tmp/sql-in-7928arv...done
Tramp: Encoding region using function `base64-encode-region'...done
Tramp: Decoding region into remote file
/plinkx:grid:/tmp/sql-out-7928Z_E...done
Tramp: Encoding region using function `base64-encode-region'...done
Tramp: Decoding region into remote file
/plinkx:grid:/tmp/sql-in-7928arv...done
psql -A  -F " "  -f "c:/tmp/sql-in-7928arv" -o "c:/tmp/sql-out-7928Z_E"
-f c:/tmp/sql-in-7928arv -o c:/tmp/sql-out-7928Z_E
No such file or directory 'c:/tmp/sql-in-7928arv'
Tramp: Inserting `/plinkx:grid:/tmp/sql-out-7928Z_E'...
Tramp: Encoding remote file /plinkx:grid:/tmp/sql-out-7928Z_E...done
Tramp: Decoding remote file /plinkx:grid:/tmp/sql-out-7928Z_E with function
base64-decode-region...
Wrote c:/Users/avorobi/AppData/Local/Temp/tramp.7928AeX
Tramp: Decoding remote file /plinkx:grid:/tmp/sql-out-7928Z_E with function
base64-decode-region...done
Tramp: Inserting `/plinkx:grid:/tmp/sql-out-7928Z_E'...done

So shell commands work but the arguments passed to psql have "c:" at the
beginning.

Thanks
Alex



On Wed, Sep 25, 2013 at 2:03 PM, Michael Albinus <michael.albinus@gmx.de>wrote:

> Eric Schulte <schulte.eric@gmail.com> writes:
>
> > I'd rather not hard-code the value of "/tmp/".  Perhaps you could rework
> > the patch so that it introduces a new customizable variable (including a
> > documentation string) so that users can set the value for their system.
>
> Will do, tomorrow. I would even prefer a more general solution, a new
> function which returns a ("the") temp directory on a remote host. This
> would be useful also outside org-mode. But this would require changes in
> Emacs/Tramp, which won't be applicable for org immediately (backwards
> compatibility, and alike).
>
> > If you can keep the patch under 15LOC we can include it w/o requiring
> > FSF copyright assignment, otherwise see [1] for contribution details.
>
> No problem. As Tramp maintainer, I have signed the FSF papers for Emacs
> 10+ years ago. This shall be valid also for org patches.
>
> > Thanks,
>
> Best regards, Michael.
>

[-- Attachment #2: Type: text/html, Size: 4277 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-09-25 20:36                         ` Alexander Vorobiev
@ 2013-09-26  8:11                           ` Michael Albinus
       [not found]                             ` <CAGOCFPXj2-3FruuD=K7=H+SQ308dzkH1P=qP0b17xQuoW9MkPQ@mail.gmail.com>
  0 siblings, 1 reply; 18+ messages in thread
From: Michael Albinus @ 2013-09-26  8:11 UTC (permalink / raw)
  To: Alexander Vorobiev
  Cc: Loris Bennett, emacs-orgmode, Johannes Rainer, Eric Schulte

Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:

> Michael,

Hi Alex,

> * this doesn't work
> #+BEGIN_SRC sql :engine postgresql :dir /grid: :results output
> select 1+2 as three;
> #+END_SRC
>
> /plinkx:grid:/tmp/sql-in-7928arv...done
> psql -A -F " " -f "c:/tmp/sql-in-7928arv" -o "c:/tmp/sql-out-7928Z_E" 
> -f c:/tmp/sql-in-7928arv -o c:/tmp/sql-out-7928Z_E
> No such file or directory 'c:/tmp/sql-in-7928arv'

Try this extended patch:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 5a032a1..2789f47 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2680,11 +2680,7 @@ Fixes a bug in
`tramp-handle-call-process-region'."
 
 (defun org-babel-local-file-name (file)
   "Return the local name component of FILE."
-  (if (file-remote-p file)
-      (let (localname)
-       (with-parsed-tramp-file-name file nil
-                                    localname))
-    file))
+  (or (file-remote-p file 'localname) file))
 
 (defun org-babel-process-file-name (name &optional no-quote-p)
   "Prepare NAME to be used in an external process.
@@ -2694,7 +2690,10 @@ remotely.  The file name is then processed by
   `expand-file-name'.
 Unless second argument NO-QUOTE-P is non-nil, the file name is
 additionally processed by `shell-quote-argument'"
   ((lambda (f) (if no-quote-p f (shell-quote-argument f)))
-   (expand-file-name (org-babel-local-file-name name))))
+   ;; We must apply `expand-file-name' on the whole filename.  If we
+   ;; would apply it on the local filename only, undesired effects
+   ;; like prepending a drive letter on MS Windows could happen.
+   (org-babel-local-file-name (expand-file-name name))))
 
 (defvar org-babel-temporary-directory)
 (unless (or noninteractive (boundp 'org-babel-temporary-directory))
@@ -2736,7 +2735,7 @@ of `org-babel-temporary-directory'."
   (if (file-remote-p default-directory)
       (let ((prefix
              (concat (file-remote-p default-directory)
-                     (expand-file-name prefix temporary-file-directory))))
+                     (expand-file-name prefix "/tmp/"))))
         (make-temp-file prefix nil suffix))
     (let ((temporary-file-directory
           (or (and (boundp 'org-babel-temporary-directory)
--8<---------------cut here---------------end--------------->8---

> Thanks
> Alex

Best regards, Michael.

PS: the analysis of your cygwin problem is delayed. I don't run MS
Windows on my machines, I need to hijack a machine from my wife or
somebody else for analysis.

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
       [not found]                               ` <87mwmzy16d.fsf@gmx.de>
@ 2013-09-26 17:28                                 ` Alexander Vorobiev
  2013-09-26 17:43                                   ` Michael Albinus
  0 siblings, 1 reply; 18+ messages in thread
From: Alexander Vorobiev @ 2013-09-26 17:28 UTC (permalink / raw)
  To: Michael Albinus, emacs-orgmode, Johannes Rainer, Loris Bennett

[-- Attachment #1: Type: text/plain, Size: 684 bytes --]

#+BEGIN_SRC sql :engine postgresql :dir /grid: :results output :colnames yes
  select 2+2 as four, 1+1 as one;
#+END_SRC

#+RESULTS:
| 4\t2 |

It works! As you see there are still some problems with ob-sql (no column
names and \t is not parsed correctly) but the remote execution seems to be
fixed.

Thanks,
Alex


On Thu, Sep 26, 2013 at 11:53 AM, Michael Albinus <michael.albinus@gmx.de>wrote:

> Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:
>
> > Hi Michael,
>
> Hi Alex,
>
> > I can't apply the patch for some reason.
>
> Strange.
>
> > Could you send it and/or new ob-core.el as a attachment?
>
> It's appended.
>
> > Thanks,
> > Alex
>
> Best regards, Michael.
>
>

[-- Attachment #2: Type: text/html, Size: 1381 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-09-26 17:28                                 ` Alexander Vorobiev
@ 2013-09-26 17:43                                   ` Michael Albinus
  0 siblings, 0 replies; 18+ messages in thread
From: Michael Albinus @ 2013-09-26 17:43 UTC (permalink / raw)
  To: Alexander Vorobiev; +Cc: Loris Bennett, emacs-orgmode, Johannes Rainer

Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:

> #+BEGIN_SRC sql :engine postgresql :dir /grid: :results output :
> colnames yes
> select 2+2 as four, 1+1 as one;
> #+END_SRC
>
> #+RESULTS:
> | 4\t2 |
>
> It works! As you see there are still some problems with ob-sql (no
> column names and \t is not parsed correctly) but the remote execution
> seems to be fixed.

Great! I will prepare the patch tomorrow, as instructed by Eric.

> Thanks,
> Alex

Best regards, Michael.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-09-25 18:15                     ` Eric Schulte
  2013-09-25 19:03                       ` Michael Albinus
@ 2013-09-27 11:39                       ` Michael Albinus
  2013-09-28 11:41                         ` Eric Schulte
  1 sibling, 1 reply; 18+ messages in thread
From: Michael Albinus @ 2013-09-27 11:39 UTC (permalink / raw)
  To: Eric Schulte
  Cc: Loris Bennett, emacs-orgmode, Alexander Vorobiev, Johannes Rainer

[-- Attachment #1: Type: text/plain, Size: 385 bytes --]

Eric Schulte <schulte.eric@gmail.com> writes:

> I'd rather not hard-code the value of "/tmp/".  Perhaps you could rework
> the patch so that it introduces a new customizable variable (including a
> documentation string) so that users can set the value for their system.
>
> Also, please package the patch with git format-patch.

Patch is appended.

> Thanks,

Best regards, Michael.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-core.el-org-babel-local-file-name-Simplify.patch --]
[-- Type: text/x-diff, Size: 2737 bytes --]

From 2b8db5486de75ec35c2c0d3e6063847cf582ace7 Mon Sep 17 00:00:00 2001
From: Michael Albinus <michael.albinus@gmx.de>
Date: Fri, 27 Sep 2013 13:34:03 +0200
Subject: [PATCH] * ob-core.el (org-babel-local-file-name): Simplify.
 (org-babel-process-file-name): Apply `expand-file-name' first.
 (org-babel-remote-temporary-directory): New defcustom. (org-babel-temp-file):
 Use it.

---
 lisp/ob-core.el | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 5a032a1..a7c227b 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2680,11 +2680,7 @@ Fixes a bug in `tramp-handle-call-process-region'."
 
 (defun org-babel-local-file-name (file)
   "Return the local name component of FILE."
-  (if (file-remote-p file)
-      (let (localname)
-	(with-parsed-tramp-file-name file nil
-				     localname))
-    file))
+  (or (file-remote-p file 'localname) file))
 
 (defun org-babel-process-file-name (name &optional no-quote-p)
   "Prepare NAME to be used in an external process.
@@ -2694,7 +2690,10 @@ remotely.  The file name is then processed by `expand-file-name'.
 Unless second argument NO-QUOTE-P is non-nil, the file name is
 additionally processed by `shell-quote-argument'"
   ((lambda (f) (if no-quote-p f (shell-quote-argument f)))
-   (expand-file-name (org-babel-local-file-name name))))
+   ;; We must apply `expand-file-name' on the whole filename.  If we
+   ;; would apply it on the local filename only, undesired effects
+   ;; like prepending a drive letter on MS Windows could happen.
+   (org-babel-local-file-name (expand-file-name name))))
 
 (defvar org-babel-temporary-directory)
 (unless (or noninteractive (boundp 'org-babel-temporary-directory))
@@ -2707,6 +2706,11 @@ additionally processed by `shell-quote-argument'"
 Used by `org-babel-temp-file'.  This directory will be removed on
 Emacs shutdown."))
 
+(defcustom org-babel-remote-temporary-directory "/tmp/"
+  "Directory to hold temporary files on remote hosts."
+  :group 'org-babel
+  :type 'string)
+
 (defmacro org-babel-result-cond (result-params scalar-form &rest table-forms)
   "Call the code to parse raw string results according to RESULT-PARAMS."
   (declare (indent 1)
@@ -2736,7 +2740,8 @@ of `org-babel-temporary-directory'."
   (if (file-remote-p default-directory)
       (let ((prefix
              (concat (file-remote-p default-directory)
-                     (expand-file-name prefix temporary-file-directory))))
+                     (expand-file-name
+		      prefix org-babel-remote-temporary-directory))))
         (make-temp-file prefix nil suffix))
     (let ((temporary-file-directory
 	   (or (and (boundp 'org-babel-temporary-directory)
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: org mode R remote code evaluation
  2013-09-27 11:39                       ` Michael Albinus
@ 2013-09-28 11:41                         ` Eric Schulte
  0 siblings, 0 replies; 18+ messages in thread
From: Eric Schulte @ 2013-09-28 11:41 UTC (permalink / raw)
  To: Michael Albinus
  Cc: Loris Bennett, emacs-orgmode, Alexander Vorobiev, Eric Schulte,
	Johannes Rainer

Michael Albinus <michael.albinus@gmx.de> writes:

> Eric Schulte <schulte.eric@gmail.com> writes:
>
>> I'd rather not hard-code the value of "/tmp/".  Perhaps you could rework
>> the patch so that it introduces a new customizable variable (including a
>> documentation string) so that users can set the value for their system.
>>
>> Also, please package the patch with git format-patch.
>
> Patch is appended.
>

Applied, Thanks for the patch!

I've also added you to the list of contributors on worg, so I shouldn't
ask you to complete the FSF paperwork again :).

Cheers,

>
>> Thanks,
>
> Best regards, Michael.
>
>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2013-09-28 12:39 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-29  6:31 org mode R remote code evaluation Johannes Rainer
2013-08-29  8:25 ` Loris Bennett
2013-08-29 10:42   ` Johannes Rainer
2013-09-23 16:45     ` Alexander Vorobiev
2013-09-24 12:57       ` Michael Albinus
2013-09-24 13:21         ` Alexander Vorobiev
2013-09-24 13:25           ` Michael Albinus
     [not found]             ` <CAGOCFPUyTaQzVTSwjUOJBfwF8vUzyw=Gn43+bHs8Go8+RUU+nA@mail.gmail.com>
2013-09-24 18:40               ` Michael Albinus
2013-09-25  4:24                 ` Alexander Vorobiev
2013-09-25 10:44                   ` Michael Albinus
2013-09-25 18:15                     ` Eric Schulte
2013-09-25 19:03                       ` Michael Albinus
2013-09-25 20:36                         ` Alexander Vorobiev
2013-09-26  8:11                           ` Michael Albinus
     [not found]                             ` <CAGOCFPXj2-3FruuD=K7=H+SQ308dzkH1P=qP0b17xQuoW9MkPQ@mail.gmail.com>
     [not found]                               ` <87mwmzy16d.fsf@gmx.de>
2013-09-26 17:28                                 ` Alexander Vorobiev
2013-09-26 17:43                                   ` Michael Albinus
2013-09-27 11:39                       ` Michael Albinus
2013-09-28 11:41                         ` Eric Schulte

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).