Subject: bug#65023: 29.1.50; Tramp 2.6.1.1 cannot be installed as ELPA package

From: Michael Albinus <[email-masked]>
Date: Sun, 06 Aug 2023 10:57:20 +0200

Jim Porter <[email-masked]> writes:

Hi Jim,

> I'm not sure if it's a good idea or not, but the following advice
> seems to fix things in Emacs 29.1 for me:
>
>   (advice-add #'loaddefs-generate--parse-file :around
>               (lambda (fn file main-outfile package-data)
>                 (funcall fn file main-outfile (or package-data t)))
>
> This makes the 'package-data' argument never be nil, which avoids
> running the broken code. I'd be a little worried about publishing this
> without further testing, but hopefully it (or something like it) could
> be a solution until 29.2 is released...

I've tried to apply this change, but it doesn't work as expected yet. I
have performed the following steps:

- Uninstall ELPA Tramp package.

- Recompile Emacs 29.1, based on commit

--8<---------------cut here---------------start------------->8---
8cbd4a02a2b (HEAD) Delete comment saying that project.el is experimental
--8<---------------cut here---------------end--------------->8---

  This is the one before your patch.

- Start emacs -Q

- Evaluate in *scratch*

--8<---------------cut here---------------start------------->8---
(use-package tramp
  :preface
  (progn
    (advice-add
     #'loaddefs-generate--parse-file
     :around (lambda (fn file main-outfile package-data)
               (funcall fn file main-outfile (or package-data t))))
    (setq package-install-upgrade-built-in t)
    (package-install 'tramp 'don-select))
  :ensure t)
--8<---------------cut here---------------end--------------->8---

This results in *scratch*

--8<---------------cut here---------------start------------->8---
;;; tramp-autoloads.el --- automatically extracted autoloads (do not edit)   -*- lexical-binding: t -*-
;; Generated by the `loaddefs-generate' function.

;; This file is part of GNU Emacs.

;;; Code:

(provide 'tramp-autoloads)

;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; no-native-compile: t
;; coding: utf-8-emacs-unix
;; End:

;;; tramp-autoloads.el ends here
;;; tramp-loaddefs.el --- automatically extracted autoloads (do not edit)   -*- lexical-binding: t -*-
;; Generated by the `loaddefs-generate' function.

;; This file is part of GNU Emacs.

;;; Code:

(provide 'tramp-loaddefs)

;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; no-native-compile: t
;; coding: utf-8-emacs-unix
;; End:

;;; tramp-loaddefs.el ends here
--8<---------------cut here---------------end--------------->8---

These parts are missing in tramp-autoloads.el and tramp-loaddefs.el. And
indeed, there is the error

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (error "Loading file /home/albinus/.emacs.d/elpa/tramp-2.6.1.1/tramp-loaddefs.el failed to provide feature ‘tramp-loaddefs’")
  require(tramp-loaddefs)
  eval-buffer(#<buffer  *load*> nil "/home/albinus/.emacs.d/elpa/tramp-2.6.1.1/tramp.el" nil t)  ; Reading at buffer position 3700
  load-with-code-conversion("/home/albinus/.emacs.d/elpa/tramp-2.6.1.1/tramp.el" "/home/albinus/.emacs.d/elpa/tramp-2.6.1.1/tramp.el" t t)
  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 (if (not (require 'tramp nil t)) (display-warning 'use-package (format "Cannot load %s" 'tramp) :error)) ((debug error) (funcall use-package--warning0 :catch err)))
  (progn (use-package-ensure-elpa 'tramp '(t) 'nil) '"Package ‘tramp’ installed." (defvar use-package--warning0 #'(lambda (keyword err) (let ((msg (format "%s/%s: %s" ... keyword ...))) (display-warning 'use-package msg :error)))) (condition-case err (if (not (require 'tramp nil t)) (display-warning 'use-package (format "Cannot load %s" 'tramp) :error)) ((debug error) (funcall use-package--warning0 :catch err))))
  (progn (progn (use-package-ensure-elpa 'tramp '(t) 'nil) '"Package ‘tramp’ installed." (defvar use-package--warning0 #'(lambda (keyword err) (let ((msg ...)) (display-warning 'use-package msg :error)))) (condition-case err (if (not (require 'tramp nil t)) (display-warning 'use-package (format "Cannot load %s" 'tramp) :error)) ((debug error) (funcall use-package--warning0 :catch err)))))
  eval((progn (progn (use-package-ensure-elpa 'tramp '(t) 'nil) '"Package ‘tramp’ installed." (defvar use-package--warning0 #'(lambda (keyword err) (let (...) (display-warning ... msg :error)))) (condition-case err (if (not (require 'tramp nil t)) (display-warning 'use-package (format "Cannot load %s" 'tramp) :error)) ((debug error) (funcall use-package--warning0 :catch err))))) t)
  elisp--eval-last-sexp(t)
  eval-last-sexp(t)
  eval-print-last-sexp(nil)
  funcall-interactively(eval-print-last-sexp nil)
  call-interactively(eval-print-last-sexp nil nil)
  command-execute(eval-print-last-sexp)
--8<---------------cut here---------------end--------------->8---