Subject: bug#20233: 24.5rc1; tramp error opening file

From: Michael Albinus <[email-masked]>
Date: Wed, 01 Apr 2015 08:51:32 +0200

[Please keep the Cc, for the public]

David Hull <[email-masked]> writes:

Hi David,

> The scp command succeeded:
>
> $ cd /tmp
> $ rm -f
> /var/folders/y9/k3f9vqgn73gf64x8ktywlkd10r0222/T/tramp.110640VR.erl
> $ scp -p -q -r -o ControlMaster=auto -o ControlPath='tramp.%r@%h:%p' -
> o ControlPersist=no
> cos6\:/home/david.hull/src/ds-advertiser-server/src/ds_adv_ox3_lineitem_v3.erl
> /var/folders/y9/k3f9vqgn73gf64x8ktywlkd10r0222/T/tramp.110640VR.erl
> $ echo $?
> 0
> $ ls -l
> /var/folders/y9/k3f9vqgn73gf64x8ktywlkd10r0222/T/tramp.110640VR.erl
> -rw-r--r-- 1 david.hull staff 11905 Mar 31 14:02
> /var/folders/y9/k3f9vqgn73gf64x8ktywlkd10r0222/T/tramp.110640VR.erl
>
> I wonder if the problem could be that the ControlPath option doesn't
> specify a directory?

Yes, indeed. This was changed back in February due to Bug#19861.

> I did a test. I put a "scp" shell script in my $HOME/bin directory
> with the following contents:
>
> #! /bin/bash
> WD=`pwd`
> echo "$WD: scp $*" >>/tmp/scp.out
> /usr/bin/scp "$@"
>
> When I attempted to use tramp, /tmp/scp.out had the following
> contents:
>
> /: scp -p -q -r -o ControlMaster=auto -o ControlPath=tramp.%r@%h:%p -o
> ControlPersist=no
> cos6:/home/david.hull/src/ds-advertiser-server/src/ds_adv_ox3_lineitem_v3.erl
> /var/folders/y9/k3f9vqgn73gf64x8ktywlkd10r0222/T/tramp.16189hTW.erl
>
> Note that the first thing on the line, the working directory, is "/".

Could you, pls, check whether the following patch works for you? It is a
backport from Emacs 25.0.50:

--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/emacs-24/lisp/net/tramp.el.~emacs-24~	2015-04-01 08:47:21.556209883 +0200
--- /home/albinus/src/emacs-24/lisp/net/tramp.el	2015-04-01 08:47:21.660211724 +0200
***************
*** 3355,3364 ****
  
  (defun tramp-handle-unhandled-file-name-directory (_filename)
    "Like `unhandled-file-name-directory' for Tramp files."
!   ;; With Emacs 23, we could simply return `nil'.  But we must keep it
!   ;; for backward compatibility.  "~/" cannot be returned, because
!   ;; there might be machines without a HOME directory (like hydra).
!   "/")
  
  (defun tramp-handle-set-visited-file-modtime (&optional time-list)
    "Like `set-visited-file-modtime' for Tramp files."
--- 3355,3365 ----
  
  (defun tramp-handle-unhandled-file-name-directory (_filename)
    "Like `unhandled-file-name-directory' for Tramp files."
!   ;; Starting with Emacs 23, we must simply return `nil'.  But we must
!   ;; keep backward compatibility, also with XEmacs.  "~/" cannot be
!   ;; returned, because there might be machines without a HOME
!   ;; directory (like hydra).
!   (and (< emacs-major-version 23) "/"))
  
  (defun tramp-handle-set-visited-file-modtime (&optional time-list)
    "Like `set-visited-file-modtime' for Tramp files."
--8<---------------cut here---------------end--------------->8---

Best regards, Michael.