0

For my require 'use-package, I'm getting cannot load file error but I really don't understand why.

In my ~/.emacs.d/init.el file, at the very top, I have

(eval-when-compile
  (require 'use-package))

(load (expand-file-name
         "load-path" (file-name-directory load-file-name)) nil t)
(add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory))
(load-library "init-emacs00")

However, in my init-emacs00 file, at the very top, I too have

(eval-when-compile
  (require 'use-package))

What strange is that my ~/.emacs.d/init.el file doesn't have such error, while my init-emacs00.el file does, as per flycheck:

enter image description here

It seems my above adding "lisp" into load-path has done something bad, but I don't know elisp except copying from working code thus I don't know how to fix the problem, I just want to add ~/.emacs.d/lisp/ to my load-path, where all my elisp resides, including my init-emacs00.el file.

That means, although it seems my above adding "lisp" is the problem, but they (all my elisp files) just load fine.

Also, I tried to add ~/.emacs.d/elpa/ to load-path myself, where the use-package is installed:

(eval-when-compile
  (add-to-list 'load-path "~/.emacs.d/elpa/")
  (require 'use-package))

enter image description here

but as we can see, that isn't working either.

UPDATE:

Thanks to db48x's help on how to find the current value of the variable, I found that,

  • user-emacs-directory’s value is "~/.emacs.d/"
  • and my load-path value already contains ~/.emacs.d/elpa/ and ~/.emacs.d/elpa/use-package-20210207.1926, when I took the above screenshots.

which makes the above flycheck warning very confusing.

4
  • Wht is the value of user-emacs-directory? Is there a lisp directory underneath that? Is the file init-emacs00 in there? BTW, it should probably be called init-emacs00.el although that does not affect whether it will be found or not.
    – NickD
    Jun 13, 2021 at 16:02
  • See my update in OP @NickD, thanks
    – xpt
    Jun 13, 2021 at 23:56
  • To find the current value of the variable, type C-h v, then type the name of the variable (in this case user-emacs-variable), and hit enter. It would also be useful to know the value of load-path after you got done with it.
    – db48x
    Jun 14, 2021 at 0:49
  • See my update in OP @db48x, thanks
    – xpt
    Jun 15, 2021 at 2:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.