spacemacs
spacemacs copied to clipboard
"git-gutter+-refresh wrong type argument" when saving and opening file with Tramp over SSH
Description :octocat:
Git gutter reports error with tramp on open and save
Reproduction guide :beetle:
- Start Emacs
- open an ssh connection with tramp (e.g. SPC f f -> /ssh:host:file)
- save file
Observed behaviour: :eyes: :broken_heart: The file saves correctly but the git-gutter+-refresh reports a wrong argument error and the same error on file open (thouugh file opens correctly).
Expected behaviour: :heart: :smile: Pretty much the same without the git-gutter error
System Info :computer:
- OS: gnu/linux
- Emacs: 26.3
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 5fcd6e31e)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
(auto-completion syntax-checking helm lsp multiple-cursors
(shell :variables shell-default-height 30 shell-default-position 'bottom)
treemacs git version-control emacs-lisp markdown org
(rust :variables rust-backend 'lsp)
(python :variables python-backend 'lsp python-fill-column 100 python-formatter 'black)
prettier react
(javascript :variables javascript-import-tool 'import-js javascript-fmt-tool 'prettier javascript-lsp-linter nil node-add-modules-path t)
(html :variables web-fmt-tool 'prettier css-enable-lsp t scss-enable-lsp t)
(typescript :variables node-add-modules-path t typescript-fmt-on-save t typescript-fmt-tool 'prettier typescript-backend 'lsp typescript-lsp-linter 'eslint))
- System configuration features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS LIBSYSTEMD LCMS2
Backtrace :paw_prints:
Saving file /ssh:HOST:FILE.json...
Tramp: Checking ‘vc-registered’ for /ssh:HOST:FILE.json...done
Saving file /ssh:HOST:FILE.json...
Tramp: Encoding local file ‘/tmp/tramp.M2enP8.json’ using ‘base64-encode-region’...done
Tramp: Decoding remote file ‘/ssh:HOST:FILE.json’ using ‘base64 -d -i >%s’...done
Wrote /ssh:HOST:FILE.json
git-gutter+-refresh: Wrong type argument: arrayp, (tramp-file-name #("ssh" 0 3 (helm-ff-file t)) nil nil #("HOST" 0 3 (helm-ff-file t)) nil "/ssh:HOST:FILE.json" nil)
Same issue here !
Found a workaround:
(remove-hook 'find-file-hook 'git-gutter+-turn-on)
The workaround doesn't work as of March 21 2020
What does work, however, is the following code snippet under (defun dotspacemacs/user-config ()):
(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)))
Source: https://github.com/nonsequitur/git-gutter-plus/pull/39#issuecomment-399374246
Edit: it works sometimes.
Both workarounds don't improve this behaviour for me...
You’re right @ngoonee, it’s not working now.
Edit: it works sometimes.
I put this inside dotspacemacs/user-config, and it seems to be working for me. The patched functions would have to be added after git-gutter+ loads.
(defun dotspacemacs/user-config ()
"Configuration for user code:
This function is called at the very end of Spacemacs startup, after layer
configuration.
Put your configuration code here, except for variables that should be set
before packages are loaded."
;; fixes to git-gutter+ when using tramp
(with-eval-after-load 'git-gutter+
;; https://github.com/syl20bnr/spacemacs/issues/12860#issuecomment-602084919
(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)))
)
)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!
Edit: it works sometimes.
I put this inside
dotspacemacs/user-config, and it seems to be working for me. The patched functions would have to be added aftergit-gutter+loads.(defun dotspacemacs/user-config () "Configuration for user code: This function is called at the very end of Spacemacs startup, after layer configuration. Put your configuration code here, except for variables that should be set before packages are loaded." ;; fixes to git-gutter+ when using tramp (with-eval-after-load 'git-gutter+ ;; https://github.com/syl20bnr/spacemacs/issues/12860#issuecomment-602084919 (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))) ) )
This definitely did the trick!
Perhaps your proposal should be integrated into Spacemacs :smile:
Thanks @datalogics-kam! This worked for me too!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!