Subject: 24.3; tramp: unhelpful error message when copy program is unavailable

From: Zack Weinberg <[email-masked]>
Date: Fri, 3 Oct 2014 14:34:25 -0400

`tramp' copies files by invoking a utility program, e.g. `rsync'.  If
that program is unavailable on the local machine, you get the unhelpful
error message `File exists, but cannot be read.'  I was only able to
figure out what was really wrong by bumping `tramp-verbose' and
inspecting the logs.  (I append a sample log.)

Recipe:

Set up two computers, A and B, such that you can `ssh' into your account
on B from your account on A.  Arrange for A not to have `rsync'
installed.  Place a test file `test.txt' in your account on B.

Then, from A, start up Emacs and set `tramp-verbose' to 6.

Then attempt to visit `/rsync:you@B:test.txt' in Emacs.

You should observe the error message `File exists, but cannot be read.'
in the echo area.

You should observe the error message

    tramp-do-copy-or-rename-file-out-of-band (1) # File error: Cannot find
    copy program: rsync

in the *debug tramp/rsync B* buffer, _and nowhere else_; especially, not
in *Messages*.

`Cannot find copy program: rsync' is a perfectly sensible error message;
this bug would be resolved if _that_ were what showed up in the echo area.

--- tramp log ---

;; GNU Emacs: 24.3.1 Tramp: 2.2.6-24.3 -*- mode: outline; -*-
14:19:05.252104 tramp-send-command (6) # echo are you awake
14:19:05.267424 tramp-wait-for-regexp (6) #
are you awake
///b9ac250b8258b97dbbec98c1e1ef1117#$
14:19:05.267725 tramp-send-command (6) # test -e
/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js
2>/dev/null; echo tramp_exit_status $?
14:19:05.283083 tramp-wait-for-regexp (6) #
tramp_exit_status 0
///b9ac250b8258b97dbbec98c1e1ef1117#$
14:19:05.284627 tramp-send-command (6) # test -d
/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js
2>/dev/null; echo tramp_exit_status $?
14:19:05.299929 tramp-wait-for-regexp (6) #
tramp_exit_status 1
///b9ac250b8258b97dbbec98c1e1ef1117#$
14:19:05.301163 tramp-sh-handle-file-truename (4) # Finding true name
for `/rsync:laguz:/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js'
14:19:05.301410 tramp-send-command (6) # echo "\"`\readlink
--canonicalize-missing
/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js`\""
2>/dev/null; echo tramp_exit_status $?
14:19:05.318470 tramp-wait-for-regexp (6) #
"/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js"
tramp_exit_status 0
///b9ac250b8258b97dbbec98c1e1ef1117#$
14:19:05.318752 tramp-sh-handle-file-truename (4) # True name of
`/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js' is
`/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js'
14:19:05.319569 tramp-do-file-attributes-with-stat (5) # file
attributes with stat:
/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js
14:19:05.319851 tramp-send-command (6) # ( (test -e
/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js || test -h
/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js) && \stat
-c '(("%N") %h %ue0 %ge0 %Xe0 %Ye0 %Ze0 %se0 "%A" t %ie0 -1)'
/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js || echo
nil) 2>/dev/null; echo tramp_exit_status $?
14:19:05.338393 tramp-wait-for-regexp (6) #
(("`/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js'") 1
1000e0 1000e0 1410395278e0 1410445328e0 1410445328e0 16933e0
"-rw-r--r--" t 48637e0 -1)
tramp_exit_status 0
///b9ac250b8258b97dbbec98c1e1ef1117#$
14:19:05.343329 tramp-handle-insert-file-contents (3) # Inserting
`/rsync:laguz:/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js'...
14:19:05.376334 tramp-do-copy-or-rename-file (0) # Copying
/rsync:laguz:/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js
to /tmp/tramp.4566iIP.js...
14:19:05.377611 tramp-do-copy-or-rename-file-out-of-band (1) # File
error: Cannot find copy program: rsync
14:19:05.378100 tramp-do-copy-or-rename-file-out-of-band (0) # Copying
/rsync:laguz:/home/tbbscraperentry/tbbscraper/scripts/pj-trace-redir.js
to /tmp/tramp.4566iIP.js...done

--- emacs config details (pruned) --

In GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.12.2)
 of 2014-09-08 on binet, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11601000
System Description:    Debian GNU/Linux unstable (sid)

Configured using:
 `configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var/lib' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3/site-lisp:/usr/share/emacs/site-lisp'
 '--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=yes'
 '--with-x-toolkit=gtk3' '--with-toolkit-scroll-bars'
 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'LDFLAGS=-Wl,-z,relro'
 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Load-path shadows:
/usr/share/emacs/24.3/site-lisp/debian-startup hides
/usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs24/site-lisp/dictionaries-common/ispell hides
/usr/share/emacs/24.3/lisp/textmodes/ispell
/usr/share/emacs24/site-lisp/dictionaries-common/flyspell hides
/usr/share/emacs/24.3/lisp/textmodes/flyspell

Features:
(shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mail-utils pp cus-edit wid-edit
help-mode vc-git edmacro kmacro js2-mode cc-mode cc-fonts easymenu
cc-guess cc-menus cc-styles cc-align cc-cmds cc-engine cc-vars cc-defs
imenu tramp-cmds noutline outline easy-mmode tramp-cache tramp-sh paren
cus-start cus-load tramp tramp-compat auth-source eieio byte-opt
bytecomp byte-compile cconv gnus-util mm-util mail-prsvr password-cache
tramp-loaddefs shell pcomplete comint ansi-color ring format-spec advice
help-fns cl-lib advice-preload time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)