reddit / emacs
Trouble with the `eglot` library.
rifasaurous · 2022-06-23 04:17
I'm trying to use the [`eglot`](https://github.com/joaotavora/eglot) library to communicate with LSP (from Haskell, but I don't think that's relevant).
When I try to start it up with `M-x eglot` in a file, I get the error `Symbol's function definition is void: project-root`. From searching the eglot discussion forums, the [usual issue](https://github.com/joaotavora/eglot/issues/549) is that the `project` library is misinstalled, but if that's the case here, it's beyond my ability to debug.
In particular:
- I did install `eglot` the standard way via `M-x package-install`. `M-x package-list-packages` does show `project` 0.8.1 installed (with status "dependency", I assume because it was pulled in as a dependency of eglot).
- `M-x find-library project` takes me to the `project.el` file for version 0.8.1 ([github link](https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/project.el)), which I think means the correct version of `project` is being loaded.
- I'm not an expert, but it looks like this library does define the `project-root` symbol.
- Following a suggestion [here](https://github.com/joaotavora/eglot/discussions/980), I tried `M-x list-load-path-shadows`, and found two relevant lines, both of which seem to indicate the version I want is shadowing other versions:
```
/home/rif/.emacs.d/elpa/project-0.8.1/project hides /usr/share/google-emacs/site-lisp/emacs-google-config/third_party/elisp/project/project
/home/rif/.emacs.d/elpa/project-0.8.1/project hides /usr/share/google-emacs/27.2+gg3+1.20210329.053400.rc147/lisp/progmodes/project
```
Any suggestions, diagnostics or lessons are welcome.
ckoneru · 2022-06-23 06:33
What version of emacs are you using?
axaxaxasmloe · 2022-06-23 10:58
The old library is probably loaded before load-path is updated, so `list-load-path-shadows` does not show you the relevant situation at load time. Maybe try calling `(package-initialize)` as early as possible in your init file. Can you figure out why project is loaded so early?
rifasaurous · 2022-06-23 11:51
At startup time I see, "This is GNU Emacs 27.2 (build 1, x86\_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2021-03-29, modified by Debian."
rifasaurous · 2022-06-23 12:03
I guess it must be this somehow, but I'm puzzled.
An interesting side note: starting emacs gives a mode-line message of `"Package cl is deprecated"`, which indicates something is loading in the (deprecated) package `cl`.
Oddly, I do not get this warning with `emacs -q`, indicating something in my init file is doing it, but I *do* get the warning if there are no uncommented lines in my `~/.emacs` or if the *only* uncommented line in my `.emacs` file is `(setq inhibit-default-init t)`, and this persists if I use `--no-site-file`. (I do not have any of `~/.emacs.el, ~/.emacs.d/init.el, ~/.config/emacs/init.el`, so I don't *think* there's some other init file.)
So I'm unsure how to find where either `cl` is being pulled in, or where `project` is being pulled in.
Should I maybe lift this up to a new top level question?
axaxaxasmloe · 2022-06-23 12:48
There's probably a package that puts `(require 'cl)` into its autoload file, which gets loaded on package activation, which in turn Emacs does automatically by default, even if there's nothing in your init file. Do you have the `list-utils` package installed? That's what's causing the warning for me. It's a bit annoying, but harmless afaict.
For figuring out how project is being loaded, the variable `load-history` may be helpful (beware, it's huge). It records loaded files with their defined symbols and provided or required features. Order is important, new entries get added at the front, but iiuc only after they're completely loaded. E.g. in my case, I have an entries `(".../xref.elc" (require . project) [...])` followed by `(".../project.elc" [...])`, so xref required project, which was loaded and added to the list, after which xref finished loading and was added in front of project.
hvis · 2022-06-23 13:26
Since `eglot` calls `project-root` and not `project-roots` (the obsolete method), it should bump its minimum version of the `project` dependency.
Seems worthy of a bug report.
rifasaurous · 2022-06-23 14:15
I can definitely see packages that are loading a (wrong) version of `project` at startup time, so this is helpful.
For some reason (related to idionsyncratic config at my company (Google)), a bunch of packages I didn't directly install are being automatically loaded at startup time. So I'll work on that.
rifasaurous · 2022-06-23 18:11
Update to close the thread (for now): passing \`--no-site-lisp\` seems to have at least locally fixed the problem.
jxfreeman · 2022-06-24 03:18
This made me LOL. Given Google’s predilection for messing with its users it seemed a humorous kind of symmetry that they also mess with their employees.