Subject: 26.1; Tramp hanging when writing version-controlled file

From: Norman Gray <[email-masked]>
Date: Tue, 4 Jun 2019 13:12:15 +0000

Tramp consistently hangs, for me, when opening or writing a remote
version-controlled file. None of the ‘why is Tramp hanging...?’
resources I've found seem to address my situation.

It seems specific to version-controlled remote files (I use Mercurial; I
haven't tested with git or others).  I'm pretty sure, but can't
guarantee, that this (ie, emacs+tramp and these machines) used to work 
OK,
so it may be a regression in something.  I'm afraid I can't put my 
finger on
specific versions here.

I'm using:
   * emacs 26.1 (on macOS, from the Nix distribution)
   * tramp 2.4.2-pre (built from git
     https://git.savannah.gnu.org/git/tramp.git, commit
     5e9e79e2508f6f04107885a5fc0726391fe3c49f)
   * remote machines are FreeBSD 11.2 and CentOS 7.6 (same behaviour on 
each)
   * I doubt it's relevant, but the remote machines have mercurial 4.6
     and 2.6.2 respectively

I create a fresh repository on the remote machine:

     $ cd checkouts/itm
     $ mkdir test
     $ cd test
     $ hg init
     $ echo hello >hello.txt
     $ hg add
     $ hg ci -m"Initial version"
     $ echo second >second.txt

Then open /scp:helium:checkouts/itm/test/hello.txt (the remote machine
is called `helium` in this case):

     Tramp: Inserting 
‘/scp:helium:/home/norman/checkouts/itm/test/hello.txt’...
     Tramp: Encoding remote file 
‘/scp:helium:/home/norman/checkouts/itm/test/hello.txt’ with 
‘openssl enc -base64 <%s’...done
     Tramp: Decoding local file 
‘/var/folders/f5/vh0d0ls94_j5s4bv49sz90s40000gn/T/tramp.w8WmcP.txt’ 
with ‘base64-decode-region’...done
     Tramp: Inserting 
‘/scp:helium:/home/norman/checkouts/itm/test/hello.txt’...done

Then it hangs.  I `C-g`, and then get:

     Tramp: Checking ‘vc-registered’ for 
/scp:helium:/home/norman/checkouts/itm/test/hello.txt...done
     Tramp: Inserting 
‘/scp:helium:/home/norman/checkouts/itm/test/hello.txt’...done

I make a change to the file, and save it:

Saving file /scp:helium:/home/norman/checkouts/itm/test/hello.txt...

     Tramp: Checking ‘vc-registered’ for 
/scp:helium:/home/norman/checkouts/itm/test/hello.txt...
     Tramp: Opening connection for helium using scp...
     Tramp: Sending command ‘exec ssh   -o ControlMaster=auto -o 
ControlPath='tramp.%C' -o ControlPersist=no -e none helium’
     Tramp: Waiting for prompts from remote shell...done
     Tramp: Found remote shell prompt on ‘helium’
     Tramp: Opening connection for helium using scp...done
     Tramp: Checking ‘vc-registered’ for 
/scp:helium:/home/norman/checkouts/itm/test/hello.txt...done
     Saving file 
/scp:helium:/home/norman/checkouts/itm/test/hello.txt...
     Tramp: Encoding local file 
‘/var/folders/f5/vh0d0ls94_j5s4bv49sz90s40000gn/T/tramp.dMysF4.txt’ 
using ‘base64-encode-region’...done
     Tramp: Decoding remote file 
‘/scp:helium:/home/norman/checkouts/itm/test/hello.txt’ using 
‘openssl enc -d -base64 >%s’...done

It hangs again.  Again `C-g`, then:

     Wrote /scp:helium:/home/norman/checkouts/itm/test/hello.txt
     Quit

The file does save successfully.  Thus the hang/wait is happening after 
the
file has been saved to the remote machine's disk

If I create a non-version-controlled file `second.txt` beside this, and
try to open, then save, this file using Tramp, this works as expected.
That is, version-controlled hello.txt works; non-controlled second.txt 
doesn't.

The messages above and below are with tramp-verbose set to 3.  I don't
get anything significantly different that I can see, with tramp-verbose
set to 10.

The shell prompt in each case should be PS1='$ ', after the
recommended/obvious rc test of $TERM. I've set the $SHELL environment
variable to /bin/bash in the Emacs process (why not...?). I've confirmed
that I do indeed get a $ prompt, with no other junk (apart from the motd
contents, which don't count as ‘junk’), when I ssh to that machine 
with
a dumb terminal; and the debugging messages Found remote shell prompt do
seem to corroborate this.  I'm not seeing this prompt string echoed
anywhere in these messages, so can't be 100% sure I haven't messed up
something there, but I'm fairly confident that the prompt string is
non-special, and in any case if this were the problem it would affect
both hello.txt and second.txt.

I've configured connection sharing as occasionally recommended, but I do
understand that Tramp carefully ignores that (and I'm mentioning it only
to indicate that I've done my homework!).

I seem to have exhausted the suggested problems in the TrampMode section
of the Emacs wiki <https://www.emacswiki.org/emacs/TrampMode#toc7> and
the Tramp manual FAQ 
<https://www.gnu.org/software/tramp/#Frequently-Asked-Questions>.

I can see some discussion of what may be this problem from 2014
<https://lists.gnu.org/archive/html/bug-gnu-emacs/2014-10/msg01232.html>,
but that thread appears to suggest that the fix is already committed
(five years ago!). I tried (setq vc-handled-backends nil) in the hope
that this might turn off any Tramp cleverness in this area, but without
effect. The Tramp manual doesn't suggest that there is any particular
cleverness in this area, in any case.

The same happens when starting Emacs with option -Q.

I asked about this problem on stackexchange
<https://emacs.stackexchange.com/questions/50801/>.  There was a mention
in comments of a recent thread
<http://lists.gnu.org/archive/html/emacs-devel/2019-05/msg00010.html>
which would potentially be relevant, but building Tramp from the
repository, as here, would presumably have picked up the associated 
fixes.

Let me know if there's anything I can add.

Best wishes,

Norman

In GNU Emacs 26.1 (build 1, x86_64-apple-darwin17.7.0, NS appkit-1561.60 
Version 10.13.6 (Build 17G65))
  of 2019-03-01 built on nixoss-iMac.local
Windowing system distributor 'Apple', version 10.3.1671
Recent messages:
Tramp: Checking ‘vc-registered’ for 
/scp:helium:/usr/home/norman/checkouts/itm/test/second.txt...done
Tramp: Inserting 
‘/scp:helium:/home/norman/checkouts/itm/test/second.txt’...done
Saving file /scp:helium:/home/norman/checkouts/itm/test/second.txt...
Tramp: Encoding local file 
‘/var/folders/f5/vh0d0ls94_j5s4bv49sz90s40000gn/T/tramp.e6feJN.txt’ 
using ‘base64-encode-region’...done
Tramp: Decoding remote file 
‘/scp:helium:/home/norman/checkouts/itm/test/second.txt’ using 
‘openssl enc -d -base64 >%s’...done
Wrote /scp:helium:/home/norman/checkouts/itm/test/second.txt
Saving file /scp:helium:/home/norman/checkouts/itm/test/second.txt...
Tramp: Encoding local file 
‘/var/folders/f5/vh0d0ls94_j5s4bv49sz90s40000gn/T/tramp.fSrL8P.txt’ 
using ‘base64-encode-region’...done
Tramp: Decoding remote file 
‘/scp:helium:/home/norman/checkouts/itm/test/second.txt’ using 
‘openssl enc -d -base64 >%s’...done
Wrote /scp:helium:/home/norman/checkouts/itm/test/second.txt

Configured using:
  'configure
  --prefix=/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1
  --with-modules --with-ns --disable-ns-self-contained
  CFLAGS=-DMAC_OS_X_VERSION_MAX_ALLOWED=101200'

Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS

Important settings:
   value of $LC_COLLATE: POSIX
   value of $LC_TIME: en_GB.UTF-8
   value of $LANG: en_GB.UTF-8
   locale-coding-system: utf-8-unix

Major mode: Text

Minor modes in effect:
   shell-dirtrack-mode: t
   show-paren-mode: t
   global-hl-line-mode: t
   delete-selection-mode: t
   tooltip-mode: t
   global-eldoc-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   line-number-mode: t
   auto-fill-function: do-auto-fill
   transient-mark-mode: t

Load-path shadows:
/Data/tools/tramp-git/share/emacs/site-lisp/tramp-smb hides 
/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/share/emacs/26.1/lisp/net/tramp-smb
/Data/tools/tramp-git/share/emacs/site-lisp/tramp-uu hides 
/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/share/emacs/26.1/lisp/net/tramp-uu
/Data/tools/tramp-git/share/emacs/site-lisp/tramp hides 
/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/share/emacs/26.1/lisp/net/tramp
/Data/tools/tramp-git/share/emacs/site-lisp/tramp-adb hides 
/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/share/emacs/26.1/lisp/net/tramp-adb
/Data/tools/tramp-git/share/emacs/site-lisp/tramp-sh hides 
/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/share/emacs/26.1/lisp/net/tramp-sh
/Data/tools/tramp-git/share/emacs/site-lisp/trampver hides 
/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/share/emacs/26.1/lisp/net/trampver
/Data/tools/tramp-git/share/emacs/site-lisp/tramp-cmds hides 
/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/share/emacs/26.1/lisp/net/tramp-cmds
/Data/tools/tramp-git/share/emacs/site-lisp/tramp-cache hides 
/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/share/emacs/26.1/lisp/net/tramp-cache
/Data/tools/tramp-git/share/emacs/site-lisp/tramp-compat hides 
/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/share/emacs/26.1/lisp/net/tramp-compat
/Data/tools/tramp-git/share/emacs/site-lisp/tramp-ftp hides 
/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/share/emacs/26.1/lisp/net/tramp-ftp
/Data/tools/tramp-git/share/emacs/site-lisp/tramp-loaddefs hides 
/nix/store/pyfdhlfcwpb6cvbbbjkp26hvp7rnkjkg-emacs-26.1/share/emacs/26.1/lisp/net/tramp-loaddefs

Features:
(shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa
epg gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mail-utils dired dired-loaddefs vc-dispatcher cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs find-func tramp-adb tramp-cache tramp-cmds tramp-ftp tramp-gvfs
zeroconf url-util dbus xml tramp-sh tramp tramp-loaddefs trampver
tramp-integration files-x tramp-compat shell pcomplete comint ansi-color
ring parse-time format-spec debug cl-extra pp cl-print thingatpt
help-fns radix-tree help-mode misearch multi-isearch vc-hg make-mode
elec-pair server paren point-stack hl-line derived mm-util mail-prsvr
ido delsel finder-inf package easymenu epg-config url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache url-vars seq byte-opt gv bytecomp byte-compile cconv
cl-loaddefs cl-lib time-date tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel term/ns-win ns-win ucs-normalize
mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote kqueue cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 274415 12408)
  (symbols 48 26899 1)
  (miscs 40 196 575)
  (strings 32 54260 1230)
  (string-bytes 1 1701753)
  (vectors 16 44910)
  (vector-slots 8 836892 16500)
  (floats 8 107 342)
  (intervals 56 738 0)
  (buffers 992 23))