Tramp with Dired produces unwanted //DIRED// line

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Tramp with Dired produces unwanted //DIRED// line

Felix E. Klee
As discussed in my [question][1] on Emacs Stack Exchange, when
connecting to an old system with an old `ls`, then I get an ugly line at
the end of each Dired buffer:

     //DIRED// 69 70 128 130 188 198 256 266 324 336 394 406

I was assuming that this is an issue with Dired and the old `ls`. I
didn’t think, it’s related to Tramp. However, Michael suggested I post
here, so I do.

Please find attached Tramp’s debug output at `tramp-verbose` level 6,
with the server and user name anonymized.

  * Tramp version: 2.4.3.27.1

  * `ls` version: ls (GNU fileutils) 3.16

[1]: https://emacs.stackexchange.com/q/64083/5327

debug_buffer.gz (54K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Tramp with Dired produces unwanted //DIRED// line

Michael Albinus
"Felix E. Klee" <[hidden email]> writes:

Hi Felix,

> As discussed in my [question][1] on Emacs Stack Exchange, when
> connecting to an old system with an old `ls`, then I get an ugly line at
> the end of each Dired buffer:
>
>      //DIRED// 69 70 128 130 188 198 256 266 324 336 394 406
>
> I was assuming that this is an issue with Dired and the old `ls`. I
> didn’t think, it’s related to Tramp. However, Michael suggested I post
> here, so I do.

You're welcome :-)

> Please find attached Tramp’s debug output at `tramp-verbose` level 6,
> with the server and user name anonymized.
>
>   * Tramp version: 2.4.3.27.1
>
>   * `ls` version: ls (GNU fileutils) 3.16

In general the traces look good, although I'm not sure whether the
//DIRED// positions are valid in your example.

I've checked the ChangeLog, and there has been some work on
tramp-sh-handle-insert-directory since Tramp 2.4.3. Perhaps you try the
recent Tramp 2.5.0.2 from GNU ELPA, and check whether it behaves better?
If not, it would be at least more simple to debug and fix on top of this
Tramp version.

Best regards, Michael.

Reply | Threaded
Open this post in threaded view
|

Re: Tramp with Dired produces unwanted //DIRED// line

Felix E. Klee
On Fri, 26 Mar 2021 at 23:00, Michael Albinus <[hidden email]>
wrote:
> Perhaps you try the recent Tramp 2.5.0.2 from GNU ELPA, and check
> whether it behaves better?

Thanks for the suggestion! I now have 2.5.0.2 installed from
<https://elpa.gnu.org/packages/>, but it doesn’t work. If I try to open:

    /plink:[hidden email]:

then I get:

    tramp-file-name-handler: Invalid function: tramp-compat-with-mutex

The same happens with `/ssh:` connections. The function
`tramp-compat-with-mutex` does exist.

Reply | Threaded
Open this post in threaded view
|

Re: Tramp with Dired produces unwanted //DIRED// line

Michael Albinus
"Felix E. Klee" <[hidden email]> writes:

Hi Felix,

>> Perhaps you try the recent Tramp 2.5.0.2 from GNU ELPA, and check
>> whether it behaves better?
>
> Thanks for the suggestion! I now have 2.5.0.2 installed from
> <https://elpa.gnu.org/packages/>, but it doesn’t work. If I try to open:
>
>     /plink:[hidden email]:
>
> then I get:
>
>     tramp-file-name-handler: Invalid function: tramp-compat-with-mutex
>
> The same happens with `/ssh:` connections. The function
> `tramp-compat-with-mutex` does exist.

Tramp fights with Emacs compatibility since ever. There is a special
package tramp-compat.el, which changes between different Tramp versions,
and it is not forward compatible. That is, if it is loaded already in
your Emacs 27.1 (running Tramp 2.4.3), there will be problems to
overload it with Tramp 2.5.0 in the running Emacs session.

So you might adapt your ~/.emacs such a way that Tramp 2.5.0.2 is in the
load-path, and you might start a new Emacs instance. As a proof of
concept, try

# emacs -Q -L ~/.emacs.d/elpa/tramp-2.5.0.2

Best regards, Michael.

Reply | Threaded
Open this post in threaded view
|

Re: Tramp with Dired produces unwanted //DIRED// line

Felix E. Klee
On Sat, 27 Mar 2021 at 16:08, Michael Albinus <[hidden email]>
wrote:
> So you might adapt your ~/.emacs such a way that Tramp 2.5.0.2 is in
> the load-path, and you might start a new Emacs instance. As a proof of
> concept, try
>
> # emacs -Q -L ~/.emacs.d/elpa/tramp-2.5.0.2

Thanks for the suggestions, but starting Emacs as above doesn’t help. I
still get the invalid function error.

Also I tried starting Emacs regularly with the following minimized
`~/.emacs` where Tramp 2.5.0.2 is in the `load-path`. Same problem.

    ;; Load Tramp before customization, or otherwise customized
    ;; connection properties are lost later:
    (add-to-list 'load-path "~/.emacs.d/elpa/tramp-2.5.0.2")
    (require 'tramp)

    (custom-set-variables
     ;; custom-set-variables was added by Custom.
     ;; If you edit it by hand, you could mess it up, so be careful.
     ;; Your init file should contain only one such instance.
     ;; If there is more than one, they won't work right.
     '(tramp-connection-properties
       '(("/ssh:pi@wall\\.lan:" "login-args"
          (("-A")
           ("-l" "%u")
           ("-p" "%p")
           ("%c")
           ("-e" "none")
           ("%h")))
         ("/plink:W1787@sites\\.inka\\.de:" "login-args"
          (("-1")
           ("-no-antispoof")
           ("-l" "%u")
           ("%h"))))))

Reply | Threaded
Open this post in threaded view
|

Re: Tramp with Dired produces unwanted //DIRED// line

Michael Albinus
"Felix E. Klee" <[hidden email]> writes:

Hi Felix,

>> So you might adapt your ~/.emacs such a way that Tramp 2.5.0.2 is in
>> the load-path, and you might start a new Emacs instance. As a proof of
>> concept, try
>>
>> # emacs -Q -L ~/.emacs.d/elpa/tramp-2.5.0.2
>
> Thanks for the suggestions, but starting Emacs as above doesn’t help. I
> still get the invalid function error.

Hmm, this shall work. I suppose you have installed Tramp 2.5.0.2 via the
package mechanism, using the same Emacs 27.1?

What happens, if you remove all *.elc files from
~/.emacs.d/elpa/tramp-2.5.0.2/ ?

And finally, this morning, I have added the following to Tramp's FAQ:

   • I get an error ‘tramp-file-name-handler: Invalid function:
     tramp-compat-with-mutex’

     Likely, you have a running Emacs session with loaded TRAMP, and
     you try to upgrade it to another version from GNU ELPA. Since
     TRAMP is not forward compatible, you must unload / reload it.
     Try the following steps:

          M-x tramp-unload-tramp <RET>
          M-x load-library <RET> tramp <RET>

Does this help?

Best regards, Michael.

Reply | Threaded
Open this post in threaded view
|

Re: Tramp with Dired produces unwanted //DIRED// line

Felix E. Klee
On Mon, 29 Mar 2021 at 22:18, Michael Albinus <[hidden email]>
wrote:
> Hmm, this shall work. I suppose you have installed Tramp 2.5.0.2 via
> the package mechanism, using the same Emacs 27.1?

Yes.

> What happens, if you remove all *.elc files from
> ~/.emacs.d/elpa/tramp-2.5.0.2/ ?

Thanks, that did the trick! Now I can start Emacs as below, and I can
log into the remote machine with Tramp 2.5.0.2.

    emacs -Q -L ~/.emacs.d/elpa/tramp-2.5.0.2

However, at the end of the Dired buffer, I still get:

    //DIRED// 69 70 128 130 188 200 258 273 331 345 403 417 475 493 551
    566 624 638 696 711 769 784 842 857 915 930 988 1002 1060 1078 1136
    1151 1209 1224 1282 1295 1353 1367 1425 1438 1496 1509 1567 1580
    1638 1645 1703 1711 1769 1777 1835 1839 1897 1903 1961 1969 2027
    2036 2094 2103 2161 2171 2229 2237 2295 2304 2362 2370 2428 2434
    2492 2499 2557 2565 2623 2632 2690 2696 2754 2764 2822 2829 2887
    2897 2955 2962 3020 3046 3104 3112 3170 3174 3232 3236 3294 3308
    3366 3374 3432 3444 3502 3508 3566 3570 3628 3632 3690 3711 3769
    3773 3831 3837

And, I just figured out that I don’t even need to load tramp explicitly.
Now, Tramp 2.5.0.2 from Elpa works also when I start Emacs as usual with
my standard configuration. That’s all after deleting the `.elc` files.

> And finally, this morning, I have added the following to Tramp's FAQ:
>
>    • I get an error ‘tramp-file-name-handler: Invalid function:
>      tramp-compat-with-mutex’
>
>      Likely, you have a running Emacs session with loaded TRAMP, and
>      you try to upgrade it to another version from GNU ELPA. Since
>      TRAMP is not forward compatible, you must unload / reload it. Try
>      the following steps:
>
>           M-x tramp-unload-tramp <RET>
>           M-x load-library <RET> tramp <RET>
>
> Does this help?

Thanks, but no need for that anymore!

Still, the issue with the Dired buffer remains.

Reply | Threaded
Open this post in threaded view
|

Re: Tramp with Dired produces unwanted //DIRED// line

Michael Albinus
"Felix E. Klee" <[hidden email]> writes:

Hi Felix,

>> What happens, if you remove all *.elc files from
>> ~/.emacs.d/elpa/tramp-2.5.0.2/ ?
>
> Thanks, that did the trick! Now I can start Emacs as below, and I can
> log into the remote machine with Tramp 2.5.0.2.
>
>     emacs -Q -L ~/.emacs.d/elpa/tramp-2.5.0.2

Good. However, I need to find out what happens with compiled Tramp
files. Hopefully, I can reproduce the problem locally.

> However, at the end of the Dired buffer, I still get:
>
>     //DIRED// 69 70 128 130 188 200 258 273 331 345 403 417 475 493 551
>     566 624 638 696 711 769 784 842 857 915 930 988 1002 1060 1078 1136
>     1151 1209 1224 1282 1295 1353 1367 1425 1438 1496 1509 1567 1580
>     1638 1645 1703 1711 1769 1777 1835 1839 1897 1903 1961 1969 2027
>     2036 2094 2103 2161 2171 2229 2237 2295 2304 2362 2370 2428 2434
>     2492 2499 2557 2565 2623 2632 2690 2696 2754 2764 2822 2829 2887
>     2897 2955 2962 3020 3046 3104 3112 3170 3174 3232 3236 3294 3308
>     3366 3374 3432 3444 3502 3508 3566 3570 3628 3632 3690 3711 3769
>     3773 3831 3837
That's OK as result from the ls command. I've played a little bit with
different versions, and it looks like Tramp assumes always a second
line, "//DIRED-OPTIONS// ...", which isn't present in your case.

The appended patch ought to fix this, could you please try?

Best regards, Michael.


attachment0 (753 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Tramp with Dired produces unwanted //DIRED// line

Felix E. Klee
On Sat, 3 Apr 2021 at 19:56, Michael Albinus <[hidden email]>
wrote:
> Good. However, I need to find out what happens with compiled Tramp
> files. Hopefully, I can reproduce the problem locally.

Let me know if I you need help reproducing the issue.

> That's OK as result from the ls command. I've played a little bit with
> different versions, and it looks like Tramp assumes always a second
> line, "//DIRED-OPTIONS// ...", which isn't present in your case.
>
> The appended patch ought to fix this, could you please try?

Your patch does get rid of the `//DIRED//` line, thank you!

Reply | Threaded
Open this post in threaded view
|

Re: Tramp with Dired produces unwanted //DIRED// line

Michael Albinus
"Felix E. Klee" <[hidden email]> writes:

Hi Felix,

>> Good. However, I need to find out what happens with compiled Tramp
>> files. Hopefully, I can reproduce the problem locally.
>
> Let me know if I you need help reproducing the issue.

Thanks for the offer. If needed, I'll contact you.

>> The appended patch ought to fix this, could you please try?
>
> Your patch does get rid of the `//DIRED//` line, thank you!

Pushed to the repositories, slightly modified. Will appear with Tramp
2.5.0.4.

Best regards, Michael.

Reply | Threaded
Open this post in threaded view
|

Re: Tramp with Dired produces unwanted //DIRED// line

Michael Albinus
Michael Albinus <[hidden email]> writes:

Hi Felix,

>>> Good. However, I need to find out what happens with compiled Tramp
>>> files. Hopefully, I can reproduce the problem locally.
>>
>> Let me know if I you need help reproducing the issue.
>
> Thanks for the offer. If needed, I'll contact you.

The upcoming Tramp 2.5.0.4 will come with the following command:

--8<---------------cut here---------------start------------->8---
(defun tramp-recompile-elpa ()
  "Recompile the installed Tramp ELPA package.
This is needed if there are compatibility problems."
  (interactive)
  ;; We expect just one Tramp package is installed.
  (when-let
      ((dir (tramp-compat-funcall
             'package-desc-dir
             (car (alist-get 'tramp (bound-and-true-p package-alist))))))
    (dolist (elc (directory-files dir 'full "\\.elc$"))
      (delete-file elc))
    (with-current-buffer (get-buffer-create byte-compile-log-buffer)
      (let ((inhibit-read-only t))
        (compilation-mode)
        (goto-char (point-max))
        (insert "\f\n")
        (call-process
         (expand-file-name invocation-name invocation-directory) nil t t
         "-Q" "-batch" "-L" dir
         "--eval" (format "(byte-recompile-directory %S 0 t)" dir))
        (message "Package `tramp' recompiled.")))))
--8<---------------cut here---------------end--------------->8---

Would you mind to check, whether it fixes the compatibility issue in
your setup? Prerequisites are that package.el is loaded, and Tramp is
installed as ELPA package. Then you can call 'M-x tramp-recompile-elpa'.
Likely, you must restart Emacs afterwards, in order to profit from the
recompiled files.

Thanks, and best regards, Michael.

Reply | Threaded
Open this post in threaded view
|

Re: Tramp with Dired produces unwanted //DIRED// line

Felix E. Klee
On Sun, 18 Apr 2021 at 17:29, Michael Albinus <[hidden email]>
wrote:
> Would you mind to check, whether it fixes the compatibility issue in
> your setup?

It worked flawlessly.

What I did:

 1. Evaluate:

        (require 'tramp)

 2. Evaluate:

        (defun tramp-recompile-elpa ()
        […]

 2. M-x tramp-version: 2.5.0.3

 3. M-x tramp-recompile-elpa

 4. Restart Emacs.

 5. Open a remote location, success!

 6. Verify successfully that the `.elc` files in
    `~/.emacs.d/elpa/tramp-2.5.0.3` are fresh.