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

doom-module-from-path couldn't handle symbolic links correctly. #7821

Open
4 tasks done
kilesduli opened this issue Apr 14, 2024 · 3 comments · May be fixed by #7826
Open
4 tasks done

doom-module-from-path couldn't handle symbolic links correctly. #7821

kilesduli opened this issue Apr 14, 2024 · 3 comments · May be fixed by #7826
Labels
is:bug Something isn't working as intended module:core Relevant to Doom core
Milestone

Comments

@kilesduli
Copy link

kilesduli commented Apr 14, 2024

I confirm that...

  • I have searched the issue tracker, documentation, FAQ, Discourse, and Google, in case this issue has already been reported/resolved.

  • I have read "How to Debug Issues", and will use it to provide as much information about this issue as possible.

  • The issue can be reproduced on the latest available commit of Doom.

  • The issue can be reproduced on a stable release of Emacs, such as 27, 28, or 29. (Unstable versions end in .50, .60, or .9x)

Expected behavior

doom-autoloads--scan correctly handles symbolic links located under doom-core-dir.

Current behavior

When doom sync calls doom-autoloads--scan to generate autoload, it will call file-truename to get the true location of the file. When a file is a symbolic link in doom-core-dir, since the actual file location is not under the doom-core-dir directory, it will not be judged as a core module, resulting in the generated init.el file not containing Contents of this file.

(cond ((string-match "/modules/\\([^/]+\\)/\\([^/]+\\)\\(?:/.*\\)?$" path)
(when-let* ((category (doom-keyword-intern (match-string 1 path)))
(module (intern (match-string 2 path))))
(and (or (null enabled-only)
(doom-module-p category module))
(cons category module))))
((file-in-directory-p path doom-core-dir)
(cons :core nil))
((file-in-directory-p path doom-user-dir)
(cons :user nil))))))

Steps to reproduce

  1. make files in doom-core-dir is symbolic links. such as :)
    image

  2. The init.el generated by doom sync does not contain them.

System Information

https://pastebin.com/cA7VhH4x

@kilesduli kilesduli added is:bug Something isn't working as intended needs-triage Issue hasn't been assessed yet labels Apr 14, 2024
@kilesduli
Copy link
Author

Actually, I think doom-user-dir also needs special handling...

@hlissner hlissner added module:core Relevant to Doom core and removed needs-triage Issue hasn't been assessed yet labels Apr 15, 2024
@hlissner hlissner added this to the Backlog milestone Apr 15, 2024
@hlissner
Copy link
Member

hlissner commented Apr 15, 2024

There must be another way. I'm not keen on supporting this degree of symlinkery madness. Calling file-truename all over the place is relatively expensive. I opt-out of it inside doom-core-dir to avoid that overhead. Why not symlink doom-core-dir itself? Or doom-emacs-dir? Every single file is madness, frankly.

In any case, I'll see if I can address this particular issue, but please reconsider that setup. Even if I manage to fix it, I don't intend to ever officially support that degree of symlinkery inside doom-core-dir (doom-user-dir, though, would make more sense).

@kilesduli
Copy link
Author

kilesduli commented Apr 16, 2024

Calling file-truename all over the place is relatively expensive. I opt-out of it inside doom-core-dir to avoid that overhead.

In fact, file-truename is called in two places:

  • The first time is when doom-sync calls doom-autoloads--scan through doom-profile--generate-doom-autoloads, and file-truename is called once in autoloads.el#172, turning the symbolic path into a real path.
  • Then, the file-in-directory-p function used in doom-module-path-from will internally call file-truename once for file and dir.

Although it seems crazy that every file is a symlink, I think a simpler solution is to replace file-in-directory-p and remove the file-truename call in doom-autoloads--scan. which can Avoiding the calling overhead also makes it work.

kilesduli added a commit to kilesduli/doomemacs that referenced this issue Apr 16, 2024
* lisp/lib/autoloads.el(doom-autoloads--scan) Remove invoke
`file-truename` of file, keeping symbolic from being converted to a real
path.
* lisp/doom-modules.el(doom-module-from-path) Replace
file-in-directory-p with string-match to determine the module to which
the file belongs.

Fix: doomemacs#7821
kilesduli added a commit to kilesduli/doomemacs that referenced this issue Apr 16, 2024
* lisp/lib/autoloads.el(doom-autoloads--scan) Remove invoke
`file-truename` of file, keeping symbolic from being converted to a real
path.
* lisp/doom-modules.el(doom-module-from-path) Replace
`file-in-directory-p` with `string-match` to determine the module to
which the file belongs.

Fix: doomemacs#7821
kilesduli added a commit to kilesduli/doomemacs that referenced this issue Apr 26, 2024
* lisp/lib/autoloads.el(doom-autoloads--scan) Remove invoke
`file-truename` of file, keeping symbolic from being converted to a real
path.
* lisp/doom-modules.el(doom-module-from-path) Replace
`file-in-directory-p` with `string-match` to determine the module to
which the file belongs.

Fix: doomemacs#7821
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:bug Something isn't working as intended module:core Relevant to Doom core
Projects
Status: Investigating
Development

Successfully merging a pull request may close this issue.

2 participants