Thanks for the quick reply!
I think ideally we should make Tramp work "out-of-the-box", even if the user
hasn't changed any of the default in their Emacs or SSH config. This would
require picking somewhere reasonable to put the ControlPath domain socket
in cases where the full expansion of a user's home directory might be too
long.
If the manual still suggests configuring OpenSSH to put the ControlPath
under /tmp/, then it seems like it would be fine to default to that behavior?
At least as a fallback in the case where the ~/.cache/emacs/ directory would
be too long.
The value of tramp-compat-temporary-file-directory could be kept as-is, since
the length isn't a problem for other use-cases. We'd just need to update the
behavior for the ControlPath domain socket.
Alex Hutcheson <alexhutcheson@google.com> writes:
Hi Alex,
> The ControlPath OpenSSH option specifies a path for a Unix domain
> socket. On Linux, domain sockets have a much lower maximum path
> length (currently 107 characters) than normal files.
>
> By default, Tramp will create a ControlPath within
> tramp-compat-temporary-file-directory. This path might be arbitrarily
> long. This can cause the generated domain socket to have a length that
> is too long, which causes the Tramp connection to fail. In this case,
> the user sees an error like:
>
> unix_listener: path
> "/usr/local/google/home/alexhutcheson/.cache/emacs/tramp.e49de70715dd5cc0f80403136e0beb44e47447f8.07oYPo8bGaOpL7Jr"
> too long for Unix domain socket
Thanks for the report, I see the problem.
> Workaround:
>
> (setq tramp-compat-temporary-file-directory "/tmp/")
Well, tramp-compat-temporary-file-directory is set to "~/.cache/emacs/"
for a reason: security. Therefore, I don't believe it is a good idea to
change it (back) to "/tmp/", as it was in previous Tramp versions.
The Tramp manual explains in subsection "5.19.3 Using ssh connection
sharing" what to do:
--8<---------------cut here---------------start------------->8---
Some OpenSSH versions support a ‘ControlPersist’ option, which allows
you to set the ‘ControlPath’ provided the variable
‘tramp-ssh-controlmaster-options’ is customized as follows:
(customize-set-variable
'tramp-ssh-controlmaster-options
(concat
"-o ControlPath=/tmp/ssh-ControlPath-%%r@%%h:%%p "
"-o ControlMaster=auto -o ControlPersist=yes"))
--8<---------------cut here---------------end--------------->8---
See (info "(tramp) Using ssh connection sharing")
Granted, not everybody remembers this explanation (or, often enough, not
everybody reads the Tramp manual at all). What about adding the
following to the Frequently Asked Questions in the manual:
--8<---------------cut here---------------start------------->8---
• I get an error ‘unix_listener: path
"/very/long/path/.cache/emacs/tramp.XXX" too long for Unix domain
socket’ when connectiong via ‘ssh’ to a remote host.
By default, TRAMP uses the directory ‘~/.cache/emacs/’ for
creation of OpenSSH Unix domain sockets. On GNU/Linux, domain
sockets have a much lower maximum path length (currently 107
characters) than normal files.
You can change this path by setting the ‘ControlPath’ OpenSSH
option, as described in *note Using ssh connection sharing:::
(customize-set-variable
'tramp-ssh-controlmaster-options
(concat
"-o ControlPath=/tmp/ssh-ControlPath-%%r@%%h:%%p "
"-o ControlMaster=auto -o ControlPersist=yes"))
--8<---------------cut here---------------end--------------->8---
Best regards, Michael.