git-gutter-plus icon indicating copy to clipboard operation
git-gutter-plus copied to clipboard

Error opening tramp files

Open peschkaj opened this issue 6 years ago • 22 comments

When opening a version controlled file via tramp, the following error is occurs and the buffer fails to focus, however the file is still opened:

git-gutter+-refresh: Wrong type argument: arrayp, (tramp-file-name "ssh" "USERNAME" nil "hostname.whatever.lol" nil #("/u/USERNAME/path/to/file.c" 66 74 (ws-butler-chg chg)) nil)

peschkaj avatar Jun 10 '18 17:06 peschkaj

Ran into same problem. See #39

yangsheng6810 avatar Jun 22 '18 09:06 yangsheng6810

Interestingly, those changes seem to lead to a timeout for tramp-file-name-handler. I attempted using the ssh command that tramp is using (ssh -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none host.name.here) and I'm successfully able to connect in my terminal.

@yangsheng6810 Were there additional steps that you had to take after modifying git-gutter+.el?

peschkaj avatar Jun 22 '18 16:06 peschkaj

No. For me it fixes the problem. Maybe because I have the following in .ssh/config:

Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p

Another possible reason is the cache of tramp. Cleanup remote connections Run tramp-clear-up-all-connections, close emacs, remove the cache file of tramp (located at .emacs.d/tramp or .emacs.d/.cache/tramp or some other similar place), remove control path socket (your tramp.%C), and start emacs.

yangsheng6810 avatar Jun 22 '18 17:06 yangsheng6810

Same problem for me when saving a tramp file.

mssun avatar Jul 10 '18 20:07 mssun

Making @yangsheng6810's changes to the .ssh/config did fix this for me.

If nothing else, those instructions should be included in the documentation for this library.

peschkaj avatar Jul 10 '18 20:07 peschkaj

@peschkaj can you specify what did you do to work around this issue? Add changes to the .ssh/config didn't fix for me.

mssun avatar Jul 10 '18 20:07 mssun

I modified my ssh config and it worked for me. Try clearing out your tramp cache as described in https://github.com/nonsequitur/git-gutter-plus/issues/42#issuecomment-399512479

peschkaj avatar Jul 10 '18 20:07 peschkaj

Unfortunately those workarounds described here didn't work for me: Emacs 26.1, Arch Linux.

kissge avatar Sep 26 '18 07:09 kissge

I am also on emacs 26.1 on Arch Linux. @kissge Did you apply the workarounds in https://github.com/nonsequitur/git-gutter-plus/pull/39 ?

yangsheng6810 avatar Sep 28 '18 16:09 yangsheng6810

@yangsheng6810 After applying this workarounds the problem still exists. git-gutter+-refresh: Wrong type argument: arrayp, (tramp-file-name #("ssh" 0 3 (helm-ff-file t)) nil nil #("USERNAME" 0 9 (helm-ff-file t)) nil "PATH_TO_FILE" nil)

This is my env info if it helps:

#### System Info :computer:
- OS: gnu/linux
- Emacs: 26.1
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 8727b3181)
- Graphic display: nil
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
‘‘‘elisp
(multiple-cursors helm emacs-lisp neotree graphviz auto-completion syntax-checking version-control spell-checking restclient git github ansible docker nginx sql markdown yaml protobuf shell windows-scripts python erlang elixir
                  (c-c++ :variables c-c++-default-mode-for-headers ’c++-mode c-c++-enable-auto-newline t c-c++-backend ’lsp-cquery c-c++-lsp-executable "/home/user/.nix-profile/bin/cquery" c-c++-lsp-sem-highlight-method ’font-lock)
                  semantic html javascript typescript react
                  (go :variables go-use-test-args "-race -timeout 30s -v" godoc-at-point-function ’godoc-gogetdoc)
                  nixos evernote org neotree emoji pdf)
‘‘‘
- System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES THREADS

szobov avatar Dec 20 '18 07:12 szobov

@szobov Have you cleaned up the cache for tramp?

Another possible reason is the cache of tramp. Cleanup remote connections Run tramp-clear-up-all-connections, close emacs, remove the cache file of tramp (located at .emacs.d/tramp or .emacs.d/.cache/tramp or some other similar place), remove control path socket (your tramp.%C), and start emacs.

yangsheng6810 avatar Dec 21 '18 16:12 yangsheng6810

@yangsheng6810 if you mean ~/emacs.d/.cache/tramp then yes.

szobov avatar Dec 22 '18 07:12 szobov

@szobov You also need to run tramp-clear-up-all-connections.

yangsheng6810 avatar Dec 22 '18 07:12 yangsheng6810

@yangsheng6810 I usually use tramp-cleanup-all-buffers plus tramp-cleanup-all-connections every time I finish with tramp.

szobov avatar Dec 22 '18 07:12 szobov

@szobov Could you toggle on toggle-debug-on-error and run it again to show the debugger and call trace? It looks to me this might be a problem related to helm.

yangsheng6810 avatar Dec 22 '18 23:12 yangsheng6810

FWIW, I ran into this when trying to manage my yadm repo with magit using tramp.

After applying the patch in #39 and restarting spacemacs, it worked fine both with find-file and spacemacs/helm-find-files.

igoralmeida avatar Dec 24 '18 01:12 igoralmeida

@igoralmeida, how did you apply the patch in #39?

I have pasted the code snippet by yangsheng6810 (below) suggested there into my spacemacs/user-config without resolving the problem.

(defun git-gutter+-remote-default-directory (dir file)
  (let* ((vec (tramp-dissect-file-name file))
          (method (tramp-file-name-method vec))
          (user (tramp-file-name-user vec))
          (domain (tramp-file-name-domain vec))
          (host (tramp-file-name-host vec))
          (port (tramp-file-name-port vec)))
     (tramp-make-tramp-file-name method user domain host port dir)))

(defun git-gutter+-remote-file-path (dir file)
  (let ((file (tramp-file-name-localname (tramp-dissect-file-name file))))
    (replace-regexp-in-string (concat "\\`" dir) "" file)))

paupereira avatar Feb 14 '19 18:02 paupereira

I don't think you're supposed to put it in your user-config. I patched git-gutter+.el directly.

igoralmeida avatar Feb 17 '19 00:02 igoralmeida

@paupereira, I have this in my spacemacs/user-config. The problem form your approach is that git-gutter+ is lazy loaded, and may be loaded after your redefinition.

(with-eval-after-load 'git-gutter+
   (defun git-gutter+-remote-default-directory (dir file)
     (let* ((vec (tramp-dissect-file-name file))
            (method (tramp-file-name-method vec))
            (user (tramp-file-name-user vec))
            (domain (tramp-file-name-domain vec))
            (host (tramp-file-name-host vec))
            (port (tramp-file-name-port vec)))
       (tramp-make-tramp-file-name method user domain host port dir)))

   (defun git-gutter+-remote-file-path (dir file)
     (let ((file (tramp-file-name-localname (tramp-dissect-file-name file))))
       (replace-regexp-in-string (concat "\\`" dir) "" file))))

yangsheng6810 avatar Feb 17 '19 14:02 yangsheng6810

Adding this previous snippet in my user-config, plus a cleanup of my tramp connections, solved it for me on emacs 26.

davidlandry93 avatar Mar 05 '19 16:03 davidlandry93

@paupereira, I have this in my spacemacs/user-config. The problem form your approach is that git-gutter+ is lazy loaded, and may be loaded after your redefinition.

(with-eval-after-load 'git-gutter+
   (defun git-gutter+-remote-default-directory (dir file)
     (let* ((vec (tramp-dissect-file-name file))
            (method (tramp-file-name-method vec))
            (user (tramp-file-name-user vec))
            (domain (tramp-file-name-domain vec))
            (host (tramp-file-name-host vec))
            (port (tramp-file-name-port vec)))
       (tramp-make-tramp-file-name method user domain host port dir)))

   (defun git-gutter+-remote-file-path (dir file)
     (let ((file (tramp-file-name-localname (tramp-dissect-file-name file))))
       (replace-regexp-in-string (concat "\\`" dir) "" file))))

Works for me, thanks!

kzjeef avatar Apr 08 '19 02:04 kzjeef

@paupereira, I have this in my spacemacs/user-config. The problem form your approach is that git-gutter+ is lazy loaded, and may be loaded after your redefinition.

(with-eval-after-load 'git-gutter+
   (defun git-gutter+-remote-default-directory (dir file)
     (let* ((vec (tramp-dissect-file-name file))
            (method (tramp-file-name-method vec))
            (user (tramp-file-name-user vec))
            (domain (tramp-file-name-domain vec))
            (host (tramp-file-name-host vec))
            (port (tramp-file-name-port vec)))
       (tramp-make-tramp-file-name method user domain host port dir)))

   (defun git-gutter+-remote-file-path (dir file)
     (let ((file (tramp-file-name-localname (tramp-dissect-file-name file))))
       (replace-regexp-in-string (concat "\\`" dir) "" file))))

works for me, emacs28+spacemacs

oouxx avatar Mar 30 '20 11:03 oouxx