Subject: Re: bug#19636: [TRAMP] global minor mode hangs connection when accessing files in :lighter

From: Philippe Vaucher <[email-masked]>
Date: Wed, 21 Jan 2015 18:40:40 +0100

>> The last command (new process) doens't complete and the TRAMP buffer
>> shows "Are you awake?". My understanding of the problem is that
>> `file-truename` tries to use a not-yet-ready TRAMP connection.
>
> I tried it seriously with several combinations of Tramp parameter
> settings; I couldn't reproduce. However, it is dangerous to run
> an asynchronous process in parallel to retrieve information via
> Tramp. While you run an asynchronous process, Tramp opens a
> second connection and remembers this channel. In parallel,
> file-truename needs also to retrieve information fron the remote
> machine, on the other connection channel. Likely, Tramp might
> confuse which connection channel to use.

Thank you for your answer.

Yes, it would be nice to be able to avoid that. The real world problem
where this happens is for `projectile-mode`, a global minor mode that
tries to detect wether you are in a project for every buffers. The
final solution will probably involve avoiding detection in buffers
where there's a process, even tho it'd make sense for the mode to work
in these buffers as well. Basically the mode displays in which project
you're in and sets up keybindings for naviguating files in this
project, hence the use of :lighter in the mode, which checks for
project root files (e.g .git/Gemfile/etc) in `default-directory` (and
parents) for the current buffer in order to determinate the project
name.

> Maybe you can set tramp-verbose to 6, and rerun your test. The resulting
> Tramp trace buffer shall tell us what's up.

I attached the TRAMP debug buffer (debug-tramp.txt) of the updated
version of my testcase. You can see that at 18:06:15.613967 it says
"are you awake" after 10 seconds of waiting. It then tries to reopen
the connection and I have to `C-g` furiously in order to recover from
it. I run my testcase in the terminal like so:

emacs -Q -l buggy-tramp-mode.el

I ran my tests on the master branch at f769566, then I updated the git
repo to 41efcf4, recompiled and ran the tests again and it failed in
the same way. The commits related to TRAMP in that range (git log
--oneline f769566..41efcf4 -- lisp/net) don't seem to be relevant, but
if you want I can give you the updated TRAMP debug buffer log.

>> To work around that was tried is to use `tramp-connectable-p` or even
>> `file-remote-p` with the appropriate flags, but they both
>> (incorrectly?) return true.
>
> (setq buggy-tramp-mode-lighter
>       '(:eval (format " Projectile[%s]"
>                       (if (file-remote-p default-directory)
>                           default-directory
>                         (file-truename default-directory)))))

That's an interesting workaround, can I assume that
`default-directory` over a TRAMP connection is always absolute? what
about symlinks?

Philippe