Open raxod502 opened 6 years ago
I am having this issue with TRAMP. I load TRAMP like this:
(use-package tramp
:straight t
:demand t
:config
;;(setq tramp-verbose 6)
(setq tramp-default-method "ssh")
(setq vc-ignore-dir-regexp
(format "\\(%s\\)\\|\\(%s\\)"
vc-ignore-dir-regexp
tramp-file-name-regexp))
;; Honor remote PATH.
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
;; Allow ssh connections to persist.
;;
;; This seems to maybe cause tramp to hang a lot.
(customize-set-variable 'tramp-use-ssh-controlmaster-options nil)
(if (eq window-system 'w32)
;(setq tramp-default-method "ssh")
(setq tramp-default-method "scp")
;(setq tramp-default-method "scpx")
(setq tramp-default-method "ssh"))
)
(autoload #'tramp-register-crypt-file-name-handler "tramp-crypt")
(require 'tramp)
However tramp-version
reports the version of the built-in TRAMP, not the one straight cloned.
Hmm, actually it seems none of config:
ran at all, as if the package was never loaded.
Hi, David. Can you please try evaluating the following test case in a buffer with lexical binding enabled?:
2021-04-23 18:50:39
gnu/linux
prerelease (HEAD -> develop, origin/develop) 4a473e5 2021-04-08
GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.4, Xaw3d scroll bars) of 2021-04-21
It will install straight.el and tramp in a clean testing environment. When it is done running, a results buffer should pop up and you can copy the results here. Thanks.
Here's what I get:
2021-04-23 18:05:45
darwin
prerelease (HEAD -> master, origin/master, origin/HEAD) e1390a9 %cs
GNU Emacs 27.2 (build 1, aarch64-apple-darwin20.2.0, NS appkit-2022.20 Version 11.1 (Build 20C69)) of 2021-04-01
Looks like this TRAMP issue:
https://www.reddit.com/r/emacs/comments/l2lw7o/tramp_blocking_emacs/
I see, can you try a slightly modified version of the test case which incorporates the workaround in that thread?:
2021-04-23 19:19:09
gnu/linux
prerelease (HEAD -> fix/clone-depth-docstring, fork/fix/clone-depth-docstring) 33aa10e 2021-04-23
GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.4, Xaw3d scroll bars) of 2021-04-21
Here ya go. Wrong TRAMP version.
2021-04-23 18:21:08
darwin
prerelease (HEAD -> master, origin/master, origin/HEAD) e1390a9 %cs
GNU Emacs 27.2 (build 1, aarch64-apple-darwin20.2.0, NS appkit-2022.20 Version 11.1 (Build 20C69)) of 2021-04-01
Interesting. Could you try this test case as well?:
2021-04-23 19:42:16
gnu/linux
prerelease (HEAD -> fix/clone-depth-docstring, fork/fix/clone-depth-docstring) 33aa10e 2021-04-23
GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.4, Xaw3d scroll bars) of 2021-04-21
No go:
2021-04-23 18:42:25
darwin
prerelease (HEAD -> master, origin/master, origin/HEAD) e1390a9 %cs
GNU Emacs 27.2 (build 1, aarch64-apple-darwin20.2.0, NS appkit-2022.20 Version 11.1 (Build 20C69)) of 2021-04-01
My apologies, I edited the test case. The defun should go before the call to straight-use-package
like so:
2021-04-23 19:42:16
gnu/linux
prerelease (HEAD -> fix/clone-depth-docstring, fork/fix/clone-depth-docstring) 33aa10e 2021-04-23
GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.4, Xaw3d scroll bars) of 2021-04-21
Still no go:
2021-04-23 18:46:14
darwin
prerelease (HEAD -> master, origin/master, origin/HEAD) e1390a9 %cs
GNU Emacs 27.2 (build 1, aarch64-apple-darwin20.2.0, NS appkit-2022.20 Version 11.1 (Build 20C69)) of 2021-04-01
There are a few things that could be happening here. Let's make sure we're actually getting the correct commit in the repo first. This test case should take care of that:
2021-04-23 20:03:32
gnu/linux
prerelease (HEAD -> fix/clone-depth-docstring, fork/fix/clone-depth-docstring) 33aa10e 2021-04-23
GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.4, Xaw3d scroll bars) of 2021-04-21
You can also try inserting the following near the top of your init file to see when tramp is being loaded:
(eval-after-load "tramp" '(debug))
It should throw you into the debugger which will (hopefully) show when Tramp is being loaded.
Might need to launch emacs with --debug-init
for it to work properly.
Here's the result of the new test:
2021-04-23 19:17:05
darwin
prerelease (HEAD -> master, origin/master, origin/HEAD) e1390a9 %cs
GNU Emacs 27.2 (build 1, aarch64-apple-darwin20.2.0, NS appkit-2022.20 Version 11.1 (Build 20C69)) of 2021-04-01
With --debug-init
I get a backtrace due to the tramp-crypt
error. The autoload hack doesn't seem to get executed I think because :config
is not executed. Perhaps :config
isn't running due to the tramp-crypt
error?
Ok, so we're cloning and building the correct version. It's just a matter of loading the correct version.
With --debug-init I get a backtrace due to the tramp-crypt error
Could you please copy that backtrace here?
The autoload hack doesn't seem to get executed I think because :config is not executed. Perhaps :config isn't running due to the tramp-crypt error?
The :config
keyword's code is expanded after requiring the package in use-package. I would try moving that to :init
in the use-package form.
Adding the autoload hack to :init
seems to get it to load via straight but the version is still wrong.
Backtrace with debug on TRAMP load:
Debugger entered: nil
(lambda nil (debug))()
funcall((lambda nil (debug)))
mapc(funcall ((lambda nil (debug))))
do-after-load-evaluation("/Users/dag/.emacs.d/straight/build/tramp/tramp.elc")
require(tramp nil t)
(not (require 'tramp nil t))
(if (not (require 'tramp nil t)) (display-warning 'use-package (format "Cannot load %s" 'tramp) :error) (condition-case err (progn (setq tramp-default-method "ssh") (setq tramp-shell-prompt-pattern "\\(?:^\\|\15\\)[^]#$%>\n]*#?[]#$%>].* *\\(^[\\[[0-9;]*[a-z...") (setq vc-ignore-dir-regexp (format "\\(%s\\)\\|\\(%s\\)" vc-ignore-dir-regexp tramp-file-name-regexp)) (if (member 'tramp-own-remote-path tramp-remote-path) tramp-remote-path (setq tramp-remote-path (cons 'tramp-own-remote-path tramp-remote-path))) (customize-set-variable 'tramp-use-ssh-controlmaster-options nil) (if (eq window-system 'w32) (setq tramp-default-method "scp") (setq tramp-default-method "ssh")) t) ((debug error) (funcall use-package--warning0 :config err))))
(progn (condition-case err (autoload #'tramp-register-crypt-file-name-handler "tramp-crypt") ((debug error) (funcall use-package--warning0 :init err))) (if (not (require 'tramp nil t)) (display-warning 'use-package (format "Cannot load %s" 'tramp) :error) (condition-case err (progn (setq tramp-default-method "ssh") (setq tramp-shell-prompt-pattern "\\(?:^\\|\15\\)[^]#$%>\n]*#?[]#$%>].* *\\(^[\\[[0-9;]*[a-z...") (setq vc-ignore-dir-regexp (format "\\(%s\\)\\|\\(%s\\)" vc-ignore-dir-regexp tramp-file-name-regexp)) (if (member 'tramp-own-remote-path tramp-remote-path) tramp-remote-path (setq tramp-remote-path (cons 'tramp-own-remote-path tramp-remote-path))) (customize-set-variable 'tramp-use-ssh-controlmaster-options nil) (if (eq window-system 'w32) (setq tramp-default-method "scp") (setq tramp-default-method "ssh")) t) ((debug error) (funcall use-package--warning0 :config err)))))
(condition-case err (progn (condition-case err (autoload #'tramp-register-crypt-file-name-handler "tramp-crypt") ((debug error) (funcall use-package--warning0 :init err))) (if (not (require 'tramp nil t)) (display-warning 'use-package (format "Cannot load %s" 'tramp) :error) (condition-case err (progn (setq tramp-default-method "ssh") (setq tramp-shell-prompt-pattern "\\(?:^\\|\15\\)[^]#$%>\n]*#?[]#$%>].* *\\(^[\\[[0-9;]*[a-z...") (setq vc-ignore-dir-regexp (format "\\(%s\\)\\|\\(%s\\)" vc-ignore-dir-regexp tramp-file-name-regexp)) (if (member 'tramp-own-remote-path tramp-remote-path) tramp-remote-path (setq tramp-remote-path (cons ... tramp-remote-path))) (customize-set-variable 'tramp-use-ssh-controlmaster-options nil) (if (eq window-system 'w32) (setq tramp-default-method "scp") (setq tramp-default-method "ssh")) t) ((debug error) (funcall use-package--warning0 :config err))))) ((debug error) (funcall use-package--warning0 :catch err)))
eval-buffer(#<buffer *load*-465418> nil "/Users/dag/lib/dotfiles/emacs/lisp/packages.el" nil t) ; Reading at buffer position 3058
load-with-code-conversion("/Users/dag/lib/dotfiles/emacs/lisp/packages.el" "/Users/dag/lib/dotfiles/emacs/lisp/packages.el" nil nil)
load("packages")
load-library("packages")
eval-buffer(#<buffer *load*> nil "/Users/dag/.emacs.d/init.el" nil t) ; Reading at buffer position 3181
load-with-code-conversion("/Users/dag/.emacs.d/init.el" "/Users/dag/.emacs.d/init.el" t t)
load("/Users/dag/.emacs.d/init" noerror nomessage)
startup--load-user-init-file(#f(compiled-function () #<bytecode 0x474bd347>) #f(compiled-function () #<bytecode 0x474bd35d>) t)
command-line()
normal-top-level()
It sure looks like it's loading from the straight repository...
Well I think I've found the problem.
The tramp-version
function inserts the defconst tramp-version
which according to trampver.el
:
;; In the Tramp GIT repository, the version number, the bug report
;; address and the required Emacs version are auto-frobbed from
;; configure.ac, so you should edit that file and run "autoconf &&
;; ./configure" to change them.
So perhaps you have the most recent version loaded, but that defconst is incorrect?
I don't think that's it:
tramp-version is a variable defined in βtramp-cmds.elβ.
Its value is "2.4.5.27.2"
This variable may be risky if used as a file-local variable.
Documentation:
This version of Tramp.
[back]
In the straight repo the defconst
is in trampver.el
.
Hmm...It seems like apropos
returns the function tramp-version
regardless of whether I select the "Function" or "Variable."
But in any case, the linked tramp-cmds.el
is from the system emacs installation.
Let's try this test case:
2021-04-23 20:58:55
gnu/linux
prerelease (HEAD -> fix/clone-depth-docstring, fork/fix/clone-depth-docstring) 33aa10e 2021-04-23
GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.4, Xaw3d scroll bars) of 2021-04-21
No dice.
2021-04-23 23:35:39
darwin
prerelease (HEAD -> master, origin/master, origin/HEAD) e1390a9 %cs
GNU Emacs 27.2 (build 1, aarch64-apple-darwin20.2.0, NS appkit-2022.20 Version 11.1 (Build 20C69)) of 2021-04-01
So I tried your latest testcase in my init.el
and it at least eliminates the need for the autoload hack:
(use-package tramp
:straight (tramp :type git
:repo "https://git.savannah.gnu.org/git/tramp.git"
:host nil
:pre-build
(("autoconf")
("./configure")
("make")))
:demand t
; :init
; (autoload #'tramp-register-crypt-file-name-handler "tramp-crypt")
:config
;;(setq tramp-verbose 6)
(setq tramp-default-method "ssh")
(setq tramp-shell-prompt-pattern "\\(?:^\\|\r\\)[^]#$%>\n]*#?[]#$%>].* *\\(^[\\[[0-9;]*[a-zA-Z] *\\)*")
(setq vc-ignore-dir-regexp
(format "\\(%s\\)\\|\\(%s\\)"
vc-ignore-dir-regexp
tramp-file-name-regexp))
;; Honor remote PATH.
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
;; Allow ssh connections to persist.
;;
;; This seems to maybe cause tramp to hang a lot.
(customize-set-variable 'tramp-use-ssh-controlmaster-options nil)
;; (customize-set-variable 'tramp-use-ssh-controlmaster-options t)
(if (eq window-system 'w32)
;(setq tramp-default-method "ssh")
(setq tramp-default-method "scp")
;(setq tramp-default-method "scpx")
(setq tramp-default-method "ssh"))
;;(setq tramp-default-method "ssh")
;;(tramp-change-syntax 'simplified)
;;(setq tramp-verbose 10)
)
However, the wrong version is still reported by tramp-version
.
If you M-x find-library trampver
, what is the output of M-x pwd
?
/opt/homebrew/Cellar/emacs-plus@28/28.0.50/share/emacs/28.0.50/lisp/net/
So it is picking up the built-in TRAMP.
Can we see the value of the load-path
variable? Might also be valuable to see the output of M-x list-load-path-shadows
.
If you have your init uploaded somewhere I can take a look to see if something is pulling in tramp before straight installs it, too.
@raxod502
I ran into this today and did some investigation.
On my machine, tramp-version
was also in the 2.4.x
range despite installing tramp
with straight.el
Interestingly, M-x find-library tramp
brought me into the straight.el
-managed checkout of tramp
, not the built-in one.
I thought it might be a shadowing issue, so I removed the built-in tramp-*.el
files from the load path to see if it would load the straight.el
-managed version that way, but instead I found that tramp wouldn't load at all because of a (require 'tramp-loaddefs)
It seems the autoloads generated as part of the build are not sufficient for loading tramp, which causes emacs to keep searching further down the load path until it finds the built-in tramp autoloads and then loads the (wrong) tramp-*.el files adjacent to the autoloads.
The checked-out tramp Makefile
was reminiscent of Org's, with a make target to build the autoloads file. If I change the recipe to the following, everything works fine:
2021-07-25 22:13:01
gnu/linux
prerelease (HEAD -> master, origin/master, origin/HEAD) 1e27b05 2021-06-13
GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.29) of 2021-07-24
Of course, this won't work on Windows, since make
won't be available, but let me know if you'd like me to put together a PR in the spirit of the Org recipe (with call-process
on an emacs child process) to fix this issue for tramp
@toshokan I haven't been able to look at this due to work but thank you for the great analysis! I'd love a commit to fix this in straight.el
but your workaround is very helpful. If nothing else we could add the workaround to the README.
Accidentally having the built-in version of Org loaded before the
straight.el
version is made available is a recurring problem. This should be solvable by introducing a new user-facing function that takes a feature name and adds advice in order to signal an error if the feature is loaded from anywhere except a package installed bystraight.el
.