7

I just started using emacs last week and everything is going well so far. I am using tramp to edit remote files as follows:

C-x C-f
/ssh:user@server:/file/to/edit

I login to the server using an ssh key, so no password is needed. Therefore I don't do anything special to start tramp and nothing has been added to my .emacs file, I simply type the above in my local emacs and it works.

The files im editing are mostly python (ie: plain text *.py files) and for the most part everything works correctly. However when I try to open some files they don't open and the following message is displayed:

gzip: stdin: unexpected end of file

Is there any way to get around this issue?

UPDATE: As suggested in the comments I enabled (setq tramp-verbose 6). The tramp debug buffer is huge (thousands of lines) so I have tried to pick out the parts that appear to be important or where some sort of error is mentioned, hopefully that will aid in figuring out what is happening:

16:11:29.124528 tramp-sh-handle-file-local-copy (3) # Encoding remote file `/ssh:myuser@myserver:/path/to/python/file.py' with `(gzip <%s | base64)'...done


16:11:29.130875 tramp-sh-handle-file-truename (4) # Finding true name for `/ssh:myuser@myserver:/path/to/python/file/'


16:11:29.131565 tramp-send-command (6) # \readlink --canonicalize-missing /path/to/python/file/ 2>/dev/null; echo tramp_exit_status $?
16:11:29.376133 tramp-wait-for-regexp (6) #

16:11:33.245252 tramp-sh-handle-file-local-copy (3) # Decoding local file `/tmp/tramp.4885Mau.py' with `(lambda (beg end) (base64-decode-region beg end) (let ((coding-system-for-write (quote binary)) (coding-system-for-read (quote binary))) (apply (quote call-process-region) (point-min) (point-max) (car (split-string gzip -d)) t t nil (cdr (split-string gzip -d)))))'...done
16:11:33.249827 tramp-call-process (6) # `chown 1000:1000 /tmp/tramp.4885Mau.py' nil nil
16:11:33.252963 tramp-call-process (6) # 0
16:11:33.255820 tramp-handle-insert-file-contents (3) # Inserting `/ssh:myuser@myserver:/path/to/python/file.py'...done


///b47a60d20b86781fc5d02f0fac35ec59#$16:11:34.975322 tramp-send-command-and-check (1) # File error: Couldn't find exit status of `( (test -e /path/to/python/file.py || test -h /path/to/python/file.py) && \stat -c '(("%N") %h %ue0 %ge0 %Xe0 %Ye0 %Ze0 %se0 "%A" t %ie0 -1)' /path/to/python/file.py || echo nil)'

The last line appears to be the actual error.

  • Show us such a file, or at least the end of it? Can you unzip it with no problem if you do that outside Emacs? – Drew Dec 14 '16 at 16:54
  • It is just a regular python text file. I presume when accessing it with tramp, it automatically gets zipped to allow for a smaller transfer size. It won't be of much help to post any of the python files because they are all quite large (over 100 lines of code). But in the end, they are just plain text python files. One thing to not is, the files were originally on my local machine and I used sftp to upload them to the server. Not sure if that matters. – darkpool Dec 14 '16 at 18:06
  • 2
    Does the problem go away if you increase the value of tramp-inline-compress-start-size to something big like 1000000? – nispio Dec 14 '16 at 19:24
  • Thanks @nispio that did the trick. Seems to be working now. Out of interest, what is the difference between your suggestion and tramp-copy-size-limit? It seems like perhaps that might have also been a solution, or not? – darkpool Dec 15 '16 at 6:37
  • 3
    We haven't actually fixed your problem, just shown that it is probably a problem with tramp's inline compression. If the files are big enough (larger than tramp-inline-compress-start-size) then tramp compresses the data on the server side and decompresses it on the client side. This only applies to files that are larger than tramp-inline-compress-start-size but smaller than tramp-copy-size-limit. – nispio Dec 15 '16 at 15:49
5

I had a similar problem when trying to open/save plain ASCII files via tramp's sftp: the files were fine, I was able to edit them with, for example,nano, but trying to open them via tramp would get rejected with the rather cryptic message: invalid string format.

This was probably related to inlining and compression, because changing those solved the issue for me. This is what I've done, using the UI:

  1. M-x customize-mode RET tramp-mode
  2. Set Tramp Copy Size Limit and Tramp Inline Compress Start Size to a very high number (1000000 in my case) to avoid out-of-the band and/or compressed data transfer. Note that, unlike the OP, I had to change both of them to get it to work. Again, this means it only works for inline, uncompressed transfer but as for the OP, this is more than enough for me since I just want to remotely edit fairly small ASCII files with the best editor that exists.

Just wanted to post it in case somebody runs into the same issue, because googling the error message didn't bring any useful results and it took me a while to figure out that it was related to the file's size (which lead me to this post). If you need additional infos or log files to solve the issue feel free to ask, but I believe you would be able to reproduce it by narrowing the above mentioned variables.

Cheers! Andres

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.