Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C-h f for some functions link to the loading file instead of their source file #1022

Open
aavanian opened this issue Dec 6, 2022 · 11 comments

Comments

@aavanian
Copy link

aavanian commented Dec 6, 2022

What's wrong

C-h f for some functions link to my init.e instead of the actual source file when straight is configured to work with use-package

Directions to reproduce

early-init.el:

(setq package-enable-at-startup nil)

init.el

;; block 1
(defvar b,ootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))
(eval-when-compile
  (straight-use-package 'use-package))
(setq straight-use-package-by-default t)

;; block2
;; (eval-when-compile
;;   (add-to-list 'load-path (concat user-emacs-directory "straight/repos/use-package"))
;;   (add-to-list 'load-path (concat user-emacs-directory "straight/repos/consult"))
;;   (add-to-list 'load-path (concat user-emacs-directory "straight/repos/compat"))
;;   (require 'use-package))

;;(straight-use-package 'consult)  ; block 3
(use-package consult)                    ; block 4

With the config above:

  • block 1 + block 4: describe-function on consult-multi-occur (for example) shows cosult-multi-occur is an autoloaded interactive native-compiled Lisp function in ‘../../../init.el’.
  • block 1 + block 3: works correctly (shows consult-multi-occur is an interactive Lisp closure in ‘consult.el’.)
  • block 2 + block 4: works correctly (same as above)

Notes

  • It started to happen after I upgraded emacs (I was on a few months old build of master without native-comp, now on the 29 branch with native-comp.
  • the problem doesn't happen for all modules/functions, it seems it's only autoloaded functions (just an intuition after checking several functions from several packages: consult, embark, marginalia, org-roam)
Test Case
(straight-bug-report
  :user-dir "/Users/aavanian/.emacs-profiles/test_consult")
  • Test run at: 2022-12-06 14:00:37
  • system-type: darwin
  • straight-version: prerelease (HEAD -> master, origin/master, origin/HEAD) 3eca39d 2022-11-25
  • emacs-version: GNU Emacs 29.0.60 (build 1, aarch64-apple-darwin22.1.0, NS appkit-2299.00 Version 13.0.1 (Build 22A400)) of 2022-12-05
Output
Test run with version: prerelease (HEAD -> master, origin/master, origin/HEAD) 3eca39d 2022-11-25
Packages:
"straight"                n/a                  master 3eca39d 2022-11-25
"org-elpa"                n/a                  n/a
"melpa"                   n/a                  master ed9e52d5 2022-12-05
"gnu-elpa-mirror"         n/a                  master a6d1865 2022-12-01
"nongnu-elpa"             n/a                  main ddfb68cf9f 2022-12-03
"el-get"                  melpa                master caf80e20 2022-11-24
"emacsmirror-mirror"      n/a                  master cae49f7 2022-11-22
"use-package"             melpa                master 9078709 2022-11-27
"bind-key"                melpa                master 9078709 2022-11-27
"consult"                 melpa                main df87710 2022-12-05
"compat"                  gnu-elpa-mirror      master 7ca7d30 2022-11-23
@aavanian aavanian added the bug label Dec 6, 2022
@progfolio
Copy link
Contributor

progfolio commented Dec 6, 2022

Is your emacs directory symlinked?

@aavanian
Copy link
Author

aavanian commented Dec 6, 2022

ah yes, not directly but a parent directory is

@progfolio
Copy link
Contributor

progfolio commented Dec 6, 2022

See: #701

This should really be fixed upstream. There is a an emacs-devel thread linked in that issue. It would be good to make some noise there as this bug could be fixed in Emacs 29 if it is acted on soon.

Once it's fixed upstream, I'd be much more willing to accept something like #945 as a workaround.

@aavanian
Copy link
Author

aavanian commented Dec 6, 2022

Thanks, I parsed quickly, if I understand correctly:

  • there's a bug open upstream
  • straight has a work-around in order to function but doesn't fix the path in the help?

Also:

  • I get same results whether I set find-file-visit-truename to nil or t (with the example above).
  • with --init-dir option to launch from the actual origin folder (so in that case path to it has no symlink), still same behaviour

@progfolio
Copy link
Contributor

there's a bug open upstream

Yes, but it has not seen any activity in quite some time.
It will not get fixed if more people don't chime in on emacs-devel.

straight has a work-around in order to function but doesn't fix the path in the help?

There's an open pr at #945, I have not tested it, so I'm not sure if it will fix the problem for you.
Ideally the problem would be fixed upstream first (because it may be a more subtle bug than the solution proposed in #945 will solve). The Emacs developers should have some insight to how to fix it.

with --init-dir option

Do you mean Emacs 29's --init-directory command line option?

@progfolio
Copy link
Contributor

please try evaluating the following test case and sharing the results of the *straight-but-report-process* buffer when it finishes:

Test Case
(straight-bug-report
  :user-dir "straight.1022"
  :post-bootstrap 
  (straight-use-package 'consult)
  (message "%s"
           (describe-function #'consult-multi-occur)))
  • Test run at: 2022-12-06 02:50:47
  • system-type: gnu/linux
  • straight-version: prerelease (HEAD -> develop, origin/develop) b89a0f7 2022-11-26
  • emacs-version: GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.35, cairo version 1.17.6) of 2022-12-02
Output
Bootstrapping straight.el...
Bootstrapping straight.el...done
Looking for gnu-elpa-mirror recipe → Cloning melpa...
Looking for gnu-elpa-mirror recipe → Cloning melpa...done
Looking for nongnu-elpa recipe → Cloning gnu-elpa-mirror...
Looking for nongnu-elpa recipe → Cloning gnu-elpa-mirror...done
Looking for emacsmirror-mirror recipe → Cloning nongnu-elpa...
Looking for emacsmirror-mirror recipe → Cloning nongnu-elpa...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) b89a0f7 2022-11-26
Cloning consult...
Cloning consult...done
Building consult...
Building consult → Cloning compat...
Building consult → Cloning compat...done
Building consult → Building compat...
Building consult → Building compat...done
Building consult...
Building consult...done

Type M-x help-quit in help window to delete it
consult-multi-occur is an autoloaded interactive Lisp function in
‘consult.el’.

(consult-multi-occur BUFS REGEXP &optional NLINES)

Improved version of ‘multi-occur’ based on ‘completing-read-multiple’.

See ‘multi-occur’ for the meaning of the arguments BUFS, REGEXP and NLINES.


Packages:
"straight"                n/a                  develop b89a0f7 2022-11-26
"org-elpa"                n/a                  n/a
"melpa"                   n/a                  master ed9e52d5 2022-12-05
"gnu-elpa-mirror"         n/a                  master a6d1865 2022-12-01
"nongnu-elpa"             n/a                  main ddfb68cf9f 2022-12-03
"el-get"                  melpa                master caf80e20 2022-11-24
"emacsmirror-mirror"      n/a                  master cae49f7 2022-11-22
"consult"                 melpa                main df87710 2022-12-05
"compat"                  gnu-elpa-mirror      master 7ca7d30 2022-11-23

@aavanian
Copy link
Author

aavanian commented Dec 6, 2022

Do you mean Emacs 29's --init-directory command line option?

sorry indeed

As for the test, see below.

Test Case
(straight-bug-report
  :user-dir "straight.1022"
  :post-bootstrap 
  (straight-use-package 'consult)
  (message "%s"
	   (describe-function #'consult-multi-occur)))
  • Test run at: 2022-12-06 16:02:47
  • system-type: darwin
  • straight-version: prerelease (HEAD -> master, origin/master, origin/HEAD) 3eca39d 2022-11-25
  • emacs-version: GNU Emacs 29.0.60 (build 1, aarch64-apple-darwin22.1.0, NS appkit-2299.00 Version 13.0.1 (Build 22A400)) of 2022-12-05
Output
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) b89a0f7 2022-11-26
Cloning consult...
Cloning consult...done
Building consult...
Building consult → Cloning compat...
Building consult → Cloning compat...done
Building consult → Building compat...
Building consult → Building compat...done
Building consult...
Building consult...done

Type M-x help-quit in help window to delete it
consult-multi-occur is an autoloaded interactive Lisp function in
‘consult.el’.

(consult-multi-occur BUFS REGEXP &optional NLINES)

Improved version of ‘multi-occur’ based on ‘completing-read-multiple’.

See ‘multi-occur’ for the meaning of the arguments BUFS, REGEXP and NLINES.


Packages:
"straight"                n/a                  develop b89a0f7 2022-11-26
"org-elpa"                n/a                  n/a
"melpa"                   n/a                  master ed9e52d5 2022-12-05
"gnu-elpa-mirror"         n/a                  master a6d1865 2022-12-01
"nongnu-elpa"             n/a                  n/a
"el-get"                  melpa                master caf80e20 2022-11-24
"emacsmirror-mirror"      n/a                  master cae49f7 2022-11-22
"consult"                 melpa                main df87710 2022-12-05
"compat"                  gnu-elpa-mirror      master 7ca7d30 2022-11-23

As explained above, this way didn't trigger the bug, only if using the use-package integration but I also ran your test with that and it worked as well, so I'm stumped as to what's different between your test and mine except it runs on straight's develop branch and assuming it's the same bootstrap code.

Test Case
(straight-bug-report
  :user-dir "straight.1022"
  :post-bootstrap 
  (eval-when-compile
    (straight-use-package 'use-package))
  (setq straight-use-package-by-default t)
  (use-package consult)
  (message "%s"
	   (describe-function #'consult-multi-occur)))
  • Test run at: 2022-12-06 16:13:13
  • system-type: darwin
  • straight-version: prerelease (HEAD -> master, origin/master, origin/HEAD) 3eca39d 2022-11-25
  • emacs-version: GNU Emacs 29.0.60 (build 1, aarch64-apple-darwin22.1.0, NS appkit-2299.00 Version 13.0.1 (Build 22A400)) of 2022-12-05
Output
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) b89a0f7 2022-11-26
Cloning use-package...
Cloning use-package...done
Building use-package...
Building use-package → Building bind-key...
Building use-package → Building bind-key...done
Building use-package...
Building use-package...done
Cloning consult...
Cloning consult...done
Building consult...
Building consult → Cloning compat...
Building consult → Cloning compat...done
Building consult → Building compat...
Building consult → Building compat...done
Building consult...
Building consult...done

Type M-x help-quit in help window to delete it
consult-multi-occur is an autoloaded interactive byte-compiled Lisp
function in ‘consult.el’.

(consult-multi-occur BUFS REGEXP &optional NLINES)

Improved version of ‘multi-occur’ based on ‘completing-read-multiple’.

See ‘multi-occur’ for the meaning of the arguments BUFS, REGEXP and NLINES.


Packages:
"straight"                n/a                  develop b89a0f7 2022-11-26
"org-elpa"                n/a                  n/a
"melpa"                   n/a                  master ed9e52d5 2022-12-05
"gnu-elpa-mirror"         n/a                  master a6d1865 2022-12-01
"nongnu-elpa"             n/a                  n/a
"el-get"                  melpa                master caf80e20 2022-11-24
"emacsmirror-mirror"      n/a                  master cae49f7 2022-11-22
"use-package"             melpa                master 9078709 2022-11-27
"bind-key"                melpa                master 9078709 2022-11-27
"consult"                 melpa                main df87710 2022-12-05
"compat"                  gnu-elpa-mirror      master 7ca7d30 2022-11-23

@aavanian
Copy link
Author

aavanian commented Dec 6, 2022

I'm stumped as to what's different between your test and mine assuming it's the same bootstrap code.

I added :preserve t to the test and I see no eln-cache directory in the test folder (I have a suspicion about that since the major difference when it started to show this behaviour is having upgraded emacs, including enabling native comp).

@progfolio
Copy link
Contributor

please try the reproduction recipe in the emacs devel thread here and let me know if you are able to reproduce the same issue:

https://lists.gnu.org/r/bug-gnu-emacs/2021-12/msg00376.html

@aavanian
Copy link
Author

aavanian commented Dec 6, 2022

can't reproduce. To note that on OSX, the built-in ln command (that I use) doesn't have the -r flag (relative paths) and that I was getting native-comp errors (I think permission issues re. gcc install between my main user and the temporary user I made to run the recipe you linked) but vertico and its function still loaded.

@aavanian
Copy link
Author

aavanian commented Dec 7, 2022

Not sure if that's helpful, but digging a bit more, it appears load-history gets duplicate entries, and symbol-file (which sources the file to display in *help*) takes the first one, which always seems to be init.el.

 Value:
(....
 ("/Users/aavanian/.emacs.d/init.el"
  ....
  (defun . consult-multi-occur)
  ....)
 ("/Users/aavanian/.emacs.d/straight/build/consult/consult.elc"
  ....
  (defun . consult-multi-occur)
  ....)
 ....)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants