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

The autoload file path is something like "../../../../../.emacs.d/straight/build/company/company" #701

Closed
nasyxx opened this issue Feb 25, 2021 · 28 comments

Comments

@nasyxx
Copy link

nasyxx commented Feb 25, 2021

What's wrong

Today, when I open my emacs, some errors happened like:

Cannot open load file: No such file or directory, 
../../../../../.emacs.d/straight/build/nasy-tools/nasy-tools-company-function

When I searched for the reason, I found some file paths of the auto-generate autoloads files inside straight/build/xx is like ../../../../../.emacs.d/straight/build/xx. E.g.:

 (custom-autoload 'global-company-mode "../../../../../.emacs.d/straight/build/company/company" nil)

  (autoload 'global-company-mode "../../../../../.emacs.d/straight/build/company/company" "\
  Toggle Company mode in all buffers.
  With prefix ARG, enable Global Company mode if ARG is positive; otherwise,
  disable it.  If called from Lisp, enable the mode if ARG is omitted or nil.

  Company mode is enabled in all buffers where `company-mode-on' would do it.

  See `company-mode' for more information on Company mode.

  \(fn &optional ARG)" t nil)

  (autoload 'company-manual-begin "../../../../../.emacs.d/straight/build/company/company" nil t nil)

My .emacs.d is a soft link of ~/.config/nasy-emacs. When using the relative position of going to the parent folders and returning, it looks for ~/.config/.emacs.d/ instead of ~/.emacs.d/ or ~/.config/nasy-emacs/

Currently, I use gsed -i 's#../../../../../.emacs.d#/Users/Nasy/.emacs.d#g' stright/build/*/*.el to do a temporary fixing.

Is there any way to force it to generate an absolute path or a relative path without "../.."?

Directions to reproduce

For "../../../../../.emacs.d/xxx", I am not sure what caused this to happen. Some of them still keep (autoload 'xx "xx").

And you could try:

git clone https://github.com/nasyxx/emacs.d.git ~/.config/nasy-emacs
ln -s $HOME/.config/nasy-emacs $HOME/.emacs.d
cd $HOME/.emacs.d/
make generate -j
emacs

Version information

@nasyxx nasyxx added the bug label Feb 25, 2021
@progfolio
Copy link
Contributor

What is the output of M-x straight-version?

@progfolio
Copy link
Contributor

progfolio commented Feb 26, 2021

Please provide the output of this as well:

(straight--autoloads-file "company")

@nasyxx
Copy link
Author

nasyxx commented Feb 26, 2021

M-x straight-version

prerelease (grafted, HEAD -> develop, origin/develop) c94516d 2021-02-23

(straight--autoloads-file "company")

"/Users/Nasy/.emacs.d/straight/build/company/company-autoloads.el"

@progfolio
Copy link
Contributor

progfolio commented Mar 9, 2021

And you could try:

git clone https://github.com/nasyxx/emacs.d.git ~/.config/nasy-emacs
ln -s $HOME/.config/nasy-emacs $HOME/.emacs.d
cd $HOME/.emacs.d/
make generate -j
emacs

Had some time to try reproducing this, but I am getting other errors with missing pieces of your config.
e.g.

(file-missing "Cannot open load file" "No such file or directory" "user-config-example")

Are you able to provide a simpler reproduction case (preferably using straight-bug-report)?

@nasyxx
Copy link
Author

nasyxx commented Mar 10, 2021

Hi,

Sorry for that. It should be work now. I have updated the Makefile to generate it.

And about this issue. I have some progress.

I notice that the nix-version emacs, build with an old macOS SDK. It uses the 10.12 version. I guess the old SDK may have issues with the new system (11.2) when I build emacs outside nix and use the latest SDK. This issue hasn't happened again.

@progfolio
Copy link
Contributor

Glad to hear everything is working now. I'm going to close this issue, but feel free to comment if you run into the issue again or have anything you'd like to add.

@dylanjm
Copy link

dylanjm commented Sep 2, 2021

I'm actually having the same problem and can verify that specific packages are generating autoloads with a hardcoded path. I've had this problem for several months now, but it goes away when I switch back to Emacs 27 from Emacs 28.

@progfolio
Copy link
Contributor

It would be helpful if you could reproduce the problem via straight-bug-report.

@dylanjm
Copy link

dylanjm commented Sep 2, 2021

Okay, after narrowing down the problem it seems to me that there is an issue with (setq find-file-visit-truename t). Similar to OP, I have my emacs symlinked from my dotfiles folder to ~/.config/emacs. Here is the output of straight-bug-report.

Test Case
(straight-bug-report
  :pre-bootstrap 
  (setq-default straight-repository-branch "develop")
  :post-bootstrap 
  (straight-use-package 'use-package)
  (use-package files :straight
    (:type built-in)
    :init
    (setq-default find-file-visit-truename t))
  (use-package editorconfig :straight t :hook
    (emacs-startup . editorconfig-mode))
  (message "bye"))
  • Test run at: 2021-09-02 15:14:35
  • system-type: darwin
  • straight-version: prerelease (HEAD -> develop, origin/develop) 45eb611 2021-08-13
  • emacs-version: GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin19.6.0, NS appkit-1894.60 Version 10.15.7 (Build 19H1323)) of 2021-09-02
Output
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) 45eb611 2021-08-13
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 editorconfig-emacs (for editorconfig)...
Cloning editorconfig-emacs (for editorconfig)...done
Building editorconfig...
Building editorconfig...done

bye
Packages:
"org-elpa"                n/a                  n/a
"melpa"                   n/a                  master ed12df24 2021-08-30
"gnu-elpa-mirror"         n/a                  master a4cb567 2021-08-29
"el-get"                  melpa                master b5a5a405 2021-09-01
"emacsmirror-mirror"      n/a                  master fc970dc 2021-08-27
"straight"                n/a                  develop 45eb611 2021-08-13
"use-package"             melpa                master a7422fb 2021-02-10
"bind-key"                melpa                master a7422fb 2021-02-10
"editorconfig"            melpa                master 2ab86dc 2021-09-02

Here is also a pretty small init.el file that can be directly tested:

;;; init.el --- Arco Emacs main configuration file -*- lexical-binding: t; -*-

(setq-default straight-repository-branch "develop")

(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
	     "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))

(straight-use-package 'use-package)

(use-package files
  :straight (:type built-in)
  :init
  (setq-default find-file-visit-truename t))

(use-package editorconfig
  :straight t
  :hook (emacs-startup . editorconfig-mode))

(provide 'init)
;;; init.el ends here

And here is the error being shown in Messages after startup:

run-hooks: Cannot open load file: No such file or directory, ../../../../../../.config/emacs/straight/build/editorconfig/editorconfig

@dylanjm
Copy link

dylanjm commented Sep 2, 2021

Okay here, I believe I have found a complete way to reproduce this.

  1. Save the above init-file to someplace like ~/dotfiles/emacs/init.el
  2. Run ln -s ~/dotfiles/emacs ~/.emacs.d
  3. Run emacs

This will give the error Cannot open load file error. What's strange is, if you symlink just the init.el it won't cause a problem. But it doesn't seem to like when the entire directory is symlinked from somewhere else.

@dylanjm
Copy link

dylanjm commented Sep 2, 2021

Also, I can only reproduce this error on Emacs 28. I just tried downgrading to 27.2 and do not get an error when launching emacs.

@progfolio progfolio reopened this Sep 3, 2021
@progfolio
Copy link
Contributor

progfolio commented Sep 16, 2021

Thanks for the additional info, @dylanjm.
This likely means something has changed in Emacs 28.

Looking through anything related to symlinks I see the following:

emacs-mirror/emacs@657fe8b

emacs-mirror/emacs@d18b1c8

emacs-mirror/emacs@d23723c

It looks like this may also be Mac specific. Not sure what the differences, if any, are on that OS.

@progfolio
Copy link
Contributor

I see someone emailed the Emacs dev thread about this, but it did not get a response. If either of you are still experiencing this issue, I would recommend joining in on that thread, as it may help the maintainers develop a solution.

https://lists.gnu.org/archive/html/emacs-devel/2021-11/msg00511.html

@jiacai2050
Copy link

@progfolio I've CCed @larsmagne in latest mail list, Hope we can get this fixed in upcoming Emacs-28.

@croqaz
Copy link

croqaz commented Dec 9, 2021

Hi all, this happens to me as well, on Arch linux, using emacs28-git from AUR.
You can check this Reddit thread where I was describing the issue: https://www.reddit.com/r/emacs/comments/rcg4r2/help_transitioning_to_emacs_28/
Somebody amazing left a comment and I ended up in this thread.

Please ask me anything.

@jiacai2050
Copy link

@croqaz Could you file a bug via report-emacs-bug and post the link to this mail thread.

@progfolio
Copy link
Contributor

@croqaz Could you file a bug via report-emacs-bug and post the link to this mail thread.

They needn't file a separate bug report. They can reply to the existing thread if they have new information to add.

@progfolio
Copy link
Contributor

Closing this issue for now. The upstream bug report shows the error is reproducible without straight.el. Unfortunately, it does not seem like it has received any attention from the maintainers. Anyone affected by this, I recommend you try the repro test provided here: https://lists.gnu.org/r/bug-gnu-emacs/2021-12/msg00376.html

If you can reproduce the error with that, it may be worth adding to that thread.

@blaenk
Copy link

blaenk commented Apr 9, 2022

I also ran into this on Windows with Emacs 28 just now (but not on Linux with Emacs 29.0). Uninstalling 28 and reinstalling 27.2 resolved it right away.

Note that the linked bug reporter mentions this workaround albeit for package-install:

Currently I use this snippet to patch the issue up:

(defun faerryn-patch-package-find-file-visit-truename (oldfun &rest r)
  (let ((find-file-visit-truename nil))
    (apply oldfun r)))
(advice-add #'package-install :around
            #'faerryn-patch-package-find-file-visit-truename)

I imagine because it's package-install that directly/indirectly causes the autoload generation, when using the stock package manager.

Does anyone know if there's a similar straight.el function we can advise for now to temporarily unset find-file-visit-truename when autoload generation occurs, then re-activate it? It seems like doing so would work around the issue which would at least allow us to use straight.el + Emacs 28 + symlink .emacs.d while the maintainers figure out the issue.

@progfolio
Copy link
Contributor

Does anyone know if there's a similar straight.el function we can advise for now to temporarily unset find-file-visit-truename when autoload generation occurs, then re-activate it?

https://github.com/raxod502/straight.el/blob/af5437f2afd00936c883124d6d3098721c2d306c/straight.el#L4979

However, advising the function is not a good solution. That function should be patched to lexically bind find-file-visit-truename. Pull requests welcome.

I would recommend bumping the linked Emacs bug report first. This should be solved upstream.

@blaenk
Copy link

blaenk commented Apr 10, 2022

Thank you @progfolio!

I suppose I'll try advising it just to see if that workaround works first.

That function should be patched to lexically bind find-file-visit-truename. Pull requests welcome.

By this, do you mean that we should add find-file-visit-truename to the let binding list? Then its value would be nil if emacs 28, otherwise take the "outer"/global value? Or would we unconditionally set it to nil?

I am definitely happy and willing to bump that bug report but admittedly I have zero idea how to go about doing that. My understanding is that this is a mailing list, so if I subscribe to the mailing list now, I won't get that email since it already happened in the past, so how can I reply to it? It's been a long while since I worked with mailing lists. Would you be kind enough to share some directions?

It seems like I'm supposed to click on this button:

image

and then also add [email protected] to the To: field based on this answer.

@blaenk
Copy link

blaenk commented Apr 10, 2022

I can confirm this workaround works:

(defun my-patch-package-find-file-visit-truename (oldfun &rest r)
  (let ((find-file-visit-truename nil))
    (apply oldfun r)))

(advice-add #'straight--build-autoloads :around
            #'my-patch-package-find-file-visit-truename)

But I acknowledge you're saying that's not the ideal solution, so I'm also happy to both:

  1. Contribute a PR for the "lexical binding" once I hear back from my earlier question and
  2. Bump that bug report once I figure out how to do so

blaenk added a commit to blaenk/dots that referenced this issue Apr 10, 2022
Without this, the autoloads end up with incorrect paths due to
using a symlink for .emacs.d

https://lists.gnu.org/r/bug-gnu-emacs/2021-12/msg00376.html
radian-software/straight.el#701
@progfolio
Copy link
Contributor

By this, do you mean that we should add find-file-visit-truename to the let binding list? Then its value would be nil if emacs 28, otherwise take the "outer"/global value? Or would we unconditionally set it to nil?

Yes, that's the general idea. Hopefully, we can unconditionally bind find-file-visit-truename to nil here:

https://github.com/raxod502/straight.el/blob/e2de88ea0e7ccf9f4846e9e756f86e0dcf469c44/straight.el#L5038-L5053

I'll have to do some testing/research to see if this is OK for versions prior to 28, or if we need to condition the value on that version.

Let's hold on that part for now and focus on getting this bug fixed upstream first.

You have the correct idea about replying to that bug. Especially the part about manually adding [email protected] as a recipient.
You can put a note in your message that mentions you're not subscribed to the mailing list and to please CC you.

Thank you for taking this on.

@blaenk
Copy link

blaenk commented Apr 10, 2022

Thank you! I did post a reply/bump yesterday, I think/hope I did it correctly:

https://lists.gnu.org/r/bug-gnu-emacs/2022-04/msg00444.html

I also subscribed to the mailing list just now.

@blaenk
Copy link

blaenk commented Apr 10, 2022

As a further note for myself, I just learned here that the bug report is visible here as well, and here.

Also added some of this information to that same wiki page. I'm not sure what "official" affiliation it has with emacs, if any (I doubt it does), but figured I'd add it there since it came up high in Google search results.

kisaragi-hiu added a commit to kisaragi-hiu/straight.el that referenced this issue Apr 30, 2022
…an-software#701)

When find-file-visit-truename, a user option, is non-nil,
make-directory-autoloads resolves symlinks in its second argument (as
it uses find-file-noselect under the hood) but not in its first. This
results in relative paths that are invalid when loaded.

See radian-software#701, radian-software#944, and upstream bug report
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=52292.
kisaragi-hiu added a commit to kisaragi-hiu/straight.el that referenced this issue Apr 30, 2022
…an-software#701)

In Emacs 28.1, when find-file-visit-truename, a user option, is
non-nil, make-directory-autoloads resolves symlinks in its second
argument (as it uses find-file-noselect under the hood) but not in its
first. This results in relative paths that are invalid when loaded.

See radian-software#701, radian-software#944, and upstream bug report
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=52292.
kisaragi-hiu added a commit to kisaragi-hiu/straight.el that referenced this issue Jun 15, 2022
…an-software#701)

In Emacs 28.1, when find-file-visit-truename, a user option, is
non-nil, make-directory-autoloads resolves symlinks in its second
argument (as it uses find-file-noselect under the hood) but not in its
first. This results in relative paths that are invalid when loaded.

See radian-software#701, radian-software#944, and upstream bug report
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=52292.
@shamindras
Copy link

shamindras commented Jun 20, 2022

Hi all - I'm experiencing a similar issue.

Note: I'm cross-posting here, because all comments point back to this thread, and my SE question is still not resolved.

I'm running emacs (v28.1) on my macOS (Montery v12.2.1) and I get the following message when trying to use magit:

command-execute: Cannot open load file: No such file or directory, ../../../../../../../.emacs.d/straight/build/magit/magit-status

My init file is here. Importantly I have my ~/.emacs.d symlinked to my dropbox folder:

.emacs.d -> ~/DROPBOX/REPOS/ss_dotfiles/.emacs.d

I tried the following suggested workarounds per:

Neither of these workarounds fix this issue with straight.el loading magit (per the example above). I've tried restarting emacs, the macOS etc, but the same problem persists.

@blaenk @progfolio @kisaragi-hiu - based on my init file, am I implementing your suggestions correctly? Any help to get this issue resolved is sincerely appreciated 🙏🏾 .

@croqaz
Copy link

croqaz commented Jun 21, 2022

Hi all, I also have the exact same problem with Emacs stable 28.1 on Arch.
I installed go-mode and I'm seeing the exact same error as above.
I eventually deleted the ~/.emacs.default/straight/build folder and restarted Emacs and now it's working, after straight + Emacs rebuilt all the repos.

@shamindras
Copy link

shamindras commented Jun 22, 2022

I eventually deleted the ~/.emacs.default/straight/build folder and restarted Emacs and now it's working, after straight + Emacs rebuilt all the repos.

@croqaz - that worked! Many thanks.

To be more precise I did the following:

  1. Backup ~/.emacs.d dir
  2. Deleted the entire ~/.emacs.d/straight dir.
  • This is more than what @croqaz suggested, but I just wanted to be quite cautious to resolve this issue.
  • Re-installing everything from scratch took less than a minute for me. Thanks to straight.el 👍🏾
  1. Ensure that (setq find-file-visit-truename nil) is included in my init file after bootstrapping straight.el.
  2. Do a quick search for setq find-file-visit-truename and check that we have set it to nil and not t anywhere else.
    • I had it set to t in my dired, which I removed.
    • This did cause me issues, but were resolved after removing it and setting it to nil only once as per above.

@croqaz - it would be good to post similar instructions on my cross-posted SE question to help others. But I would like you to get the credit and points for it. Are you able to post your advice above as an answer on my SE question? Else I will do it myself on Sunday. Update: As discussed, I've now included an answer in the stackexchange post and made sure to credit @croqaz as mentioned.

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

No branches or pull requests

8 participants