radian-software / straight.el

πŸ€ Next-generation, purely functional package manager for the Emacs hacker.
MIT License
2.75k stars 151 forks source link

Add way to suppress built-in packages #236

Open raxod502 opened 6 years ago

raxod502 commented 6 years ago

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 by straight.el.

david-greene-cb commented 3 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.

david-greene-cb commented 3 years ago

Hmm, actually it seems none of config: ran at all, as if the package was never loaded.

progfolio commented 3 years ago

Hi, David. Can you please try evaluating the following test case in a buffer with lexical binding enabled?:

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-version.straight" :post-bootstrap (straight-use-package 'tramp) (require 'tramp) (message "%S" (tramp-version nil))) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) 3306647 2021-04-18 Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done 2.5.1-pre "2.5.1-pre" Packages: "org-elpa" n/a n/a "melpa" n/a master d4ababc7 2021-04-20 "gnu-elpa-mirror" n/a master 3e7e586 2021-04-17 "el-get" melpa master 84dd1837 2021-02-07 "emacsmirror-mirror" n/a master 1c24bce 2021-04-08 "straight" n/a develop 3306647 2021-04-18 "tramp" gnu-elpa-mirror master 6f69a0b 2021-03-30 ```

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.

david-greene-cb commented 3 years ago

Here's what I get:

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-version.straight" :post-bootstrap (straight-use-package 'tramp) (require 'tramp) (message "%S" (tramp-version nil))) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) 3306647 %cs Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done Debugger entered--Lisp error: (void-function tramp-register-crypt-file-name-handler) tramp-register-crypt-file-name-handler() tramp-register-file-name-handlers() #f(compiled-function () #)() run-hooks(tramp--startup-hook) byte-code("\301\302!\210\303\300!\210\304\211\20\207" [tramp--startup-hook provide tramp run-hooks nil] 3) require(tramp) (let ((straight-bug-report-args '(:post-bootstrap (progn (straight-use-package 'tramp) (require 'tramp) (message "%S" (tramp-version nil))) :user-dir "/var/folders/8f/w80247hn2fd84p4sf0jmzj3m0000gn/T/t..." :executable "/opt/homebrew/Cellar/emacs-plus@27/27.2/Emacs.app/..."))) (setq user-emacs-directory "/var/folders/8f/w80247hn2fd84p4sf0jmzj3m0000gn/T/t...") (setq straight-repository-branch "develop") (setq debug-on-error t) (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 5)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously (concat "https://raw.githubusercontent.com/" "raxod502/straight.el/develop/install.el") 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) (condition-case nil (message "Test run with version: %s" (straight-version)) (error nil)) (straight-use-package 'tramp) (require 'tramp) (message "%S" (tramp-version nil))) eval((let ((straight-bug-report-args '(:post-bootstrap (progn (straight-use-package ...) (require ...) (message "%S" ...)) :user-dir "/var/folders/8f/w80247hn2fd84p4sf0jmzj3m0000gn/T/t..." :executable "/opt/homebrew/Cellar/emacs-plus@27/27.2/Emacs.app/..."))) (setq user-emacs-directory "/var/folders/8f/w80247hn2fd84p4sf0jmzj3m0000gn/T/t...") (setq straight-repository-branch "develop") (setq debug-on-error t) (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 5)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously (concat "https://raw.githubusercontent.com/" "raxod502/straight.el/develop/install.el") 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) (condition-case nil (message "Test run with version: %s" (straight-version)) (error nil)) (straight-use-package 'tramp) (require 'tramp) (message "%S" (tramp-version nil))) t) command-line-1(("--eval" "(let\n ((straight-bug-report-args\n '(:post-...")) command-line() normal-top-level() ```
david-greene-cb commented 3 years ago

Looks like this TRAMP issue:

https://www.reddit.com/r/emacs/comments/l2lw7o/tramp_blocking_emacs/

progfolio commented 3 years ago

I see, can you try a slightly modified version of the test case which incorporates the workaround in that thread?:

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-version.straight" :post-bootstrap (straight-use-package 'tramp) (autoload #'tramp-register-crypt-file-name-handler "tramp-crypt") (require 'tramp) (tramp-version nil)) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) 3306647 2021-04-18 Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done 2.5.1-pre Packages: "org-elpa" n/a n/a "melpa" n/a master d4ababc7 2021-04-20 "gnu-elpa-mirror" n/a master 3e7e586 2021-04-17 "el-get" melpa master 84dd1837 2021-02-07 "emacsmirror-mirror" n/a master 1c24bce 2021-04-08 "straight" n/a develop 3306647 2021-04-18 "tramp" gnu-elpa-mirror master 6f69a0b 2021-03-30 ```
david-greene-cb commented 3 years ago

Here ya go. Wrong TRAMP version.

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-version.straight" :post-bootstrap (straight-use-package 'tramp) (autoload #'tramp-register-crypt-file-name-handler "tramp-crypt") (require 'tramp) (tramp-version nil)) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) 3306647 %cs Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done 2.4.5.27.2 ```
progfolio commented 3 years ago

Interesting. Could you try this test case as well?:

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-version.straight" :post-bootstrap (defun tramp-register-crypt-file-name-handler (&rest _args) nil) (straight-use-package 'tramp) (require 'tramp) (tramp-version nil)) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) 3306647 2021-04-18 Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done 2.5.1-pre Packages: "org-elpa" n/a n/a "melpa" n/a master d4ababc7 2021-04-20 "gnu-elpa-mirror" n/a master 3e7e586 2021-04-17 "el-get" melpa master 84dd1837 2021-02-07 "emacsmirror-mirror" n/a master 1c24bce 2021-04-08 "straight" n/a develop 3306647 2021-04-18 "tramp" gnu-elpa-mirror master 6f69a0b 2021-03-30 ```
david-greene-cb commented 3 years ago

No go:

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-version.straight" :post-bootstrap (straight-use-package 'tramp) (defun tramp-register-crypt-file-name-handler (&rest _args) nil) (require 'tramp) (tramp-version nil)) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) 3306647 %cs Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done 2.4.5.27.2 ```
progfolio commented 3 years ago

My apologies, I edited the test case. The defun should go before the call to straight-use-package like so:

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-version.straight" :post-bootstrap (defun tramp-register-crypt-file-name-handler (&rest _args) nil) (straight-use-package 'tramp) (require 'tramp) (tramp-version nil)) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) 3306647 2021-04-18 Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done 2.5.1-pre Packages: "org-elpa" n/a n/a "melpa" n/a master d4ababc7 2021-04-20 "gnu-elpa-mirror" n/a master 3e7e586 2021-04-17 "el-get" melpa master 84dd1837 2021-02-07 "emacsmirror-mirror" n/a master 1c24bce 2021-04-08 "straight" n/a develop 3306647 2021-04-18 "tramp" gnu-elpa-mirror master 6f69a0b 2021-03-30 ```
david-greene-cb commented 3 years ago

Still no go:

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-version.straight" :post-bootstrap (defun tramp-register-crypt-file-name-handler (&rest _args) nil) (straight-use-package 'tramp) (require 'tramp) (tramp-version nil)) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) 3306647 %cs Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done 2.4.5.27.2 ```
progfolio commented 3 years ago

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:

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-version.straight" :post-bootstrap (straight-use-package 'tramp) (let ((default-directory (straight--repos-dir "tramp"))) (message "%S" (straight--process-output "git" "log" "HEAD^..HEAD")))) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) 3306647 2021-04-18 Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done "commit 6f69a0ba117f78265279dd418fa0bc042989f8d5 Author: GNU ELPA Mirror Bot Date: Tue Mar 30 15:22:36 2021 +0000 Update tramp Timestamp: 2021-03-30 15:18:41 GNU ELPA commit: b2f8d97feb99aa9970f65b6d26d1904c1cb3c43e Emacs commit: 49cbf2392ba51c2ebd866b062dbf7908c595466f" Packages: "org-elpa" n/a n/a "melpa" n/a master d4ababc7 2021-04-20 "gnu-elpa-mirror" n/a master 3e7e586 2021-04-17 "el-get" melpa master 84dd1837 2021-02-07 "emacsmirror-mirror" n/a master 1c24bce 2021-04-08 "straight" n/a develop 3306647 2021-04-18 "tramp" gnu-elpa-mirror master 6f69a0b 2021-03-30 ```
progfolio commented 3 years ago

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.

david-greene-cb commented 3 years ago

Here's the result of the new test:

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-version.straight" :post-bootstrap (straight-use-package 'tramp) (let ((default-directory (straight--repos-dir "tramp"))) (message "%S" (straight--process-output "git" "log" "HEAD^..HEAD")))) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) f790b05 %cs Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done "commit 6f69a0ba117f78265279dd418fa0bc042989f8d5 Author: GNU ELPA Mirror Bot Date: Tue Mar 30 15:22:36 2021 +0000 Update tramp Timestamp: 2021-03-30 15:18:41 GNU ELPA commit: b2f8d97feb99aa9970f65b6d26d1904c1cb3c43e Emacs commit: 49cbf2392ba51c2ebd866b062dbf7908c595466f" ```
david-greene-cb commented 3 years ago

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?

progfolio commented 3 years ago

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.

david-greene-cb commented 3 years ago

Adding the autoload hack to :init seems to get it to load via straight but the version is still wrong.

david-greene-cb commented 3 years ago

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...

progfolio commented 3 years ago

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.
progfolio commented 3 years ago

So perhaps you have the most recent version loaded, but that defconst is incorrect?

david-greene-cb commented 3 years ago

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.

progfolio commented 3 years ago

Let's try this test case:

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-test.straight" :post-bootstrap (straight-use-package '(tramp :type git :repo "https://git.savannah.gnu.org/git/tramp.git" :host nil :pre-build (("autoconf") ("./configure") ("make")))) (require 'tramp) (tramp-version nil)) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) f790b05 2021-04-23 Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done 2.5.1-pre Packages: "org-elpa" n/a n/a "melpa" n/a master d4ababc7 2021-04-20 "gnu-elpa-mirror" n/a master 3e7e586 2021-04-17 "el-get" melpa master 84dd1837 2021-02-07 "emacsmirror-mirror" n/a master 1c24bce 2021-04-08 "straight" n/a develop f790b05 2021-04-23 "tramp" gnu-elpa-mirror master 5a992d7b 2021-04-23 ```
david-greene-cb commented 3 years ago

No dice.

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-test.straight" :post-bootstrap (straight-use-package '(tramp :type git :repo "https://git.savannah.gnu.org/git/tramp.git" :host nil :pre-build (("autoconf") ("./configure") ("make")))) (require 'tramp) (tramp-version nil)) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) f790b05 %cs Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done 2.4.5.27.2 ```
david-greene-cb commented 3 years ago

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.

progfolio commented 3 years ago

If you M-x find-library trampver, what is the output of M-x pwd?

david-greene-cb commented 3 years ago

/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.

progfolio commented 3 years ago

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.

progfolio commented 3 years ago

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.

toshokan commented 3 years ago

@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:

Test Case ```emacs-lisp (straight-bug-report :user-dir "tramp-test.straight" :post-bootstrap (straight-use-package '(tramp :build t :pre-build (("make" "autoloads")))) (require 'tramp) (tramp-version nil)) ```
Output ```emacs-lisp Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe β†’ Cloning melpa... Looking for gnu-elpa-mirror recipe β†’ Cloning melpa...done Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe β†’ Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe β†’ Cloning el-get... Looking for emacsmirror-mirror recipe β†’ Cloning el-get...done Looking for straight recipe β†’ Cloning emacsmirror-mirror... Looking for straight recipe β†’ Cloning emacsmirror-mirror...done Building straight... Building straight...done Test run with version: prerelease (HEAD -> develop, origin/develop) 08b0ecf 2021-07-24 Cloning tramp... Cloning tramp...done Building tramp... Building tramp...done 2.5.1 Packages: "org-elpa" n/a n/a "melpa" n/a master f0f88655 2021-07-25 "gnu-elpa-mirror" n/a master 0ed8c5a 2021-07-17 "el-get" melpa master 463f5e98 2021-07-06 "emacsmirror-mirror" n/a master b0d7728 2021-07-26 "straight" n/a develop 08b0ecf 2021-07-24 "tramp" gnu-elpa-mirror master 8c183a5 2021-06-30 ```

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

david-greene-cb commented 3 years ago

@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.