Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
901 stars 98 forks source link

Emacs doesn't find irony installed via apt #583

Closed ducbueno closed 2 years ago

ducbueno commented 2 years ago

Hello everyone.

So, I've successfully installed irony via apt (sudo apt install elpa-irony) but Emacs doesn't seem to be able to find it, since I keep getting the message "Irony server isn't installed" whenever I open a C++ file. This kept happening even after a system reboot.

What am I missing here?

Thanks in advance!

Sarcasm commented 2 years ago

Hello,

The Debian package configures the right install prefix (/usr) to my knowledge. @sten0 can maybe confirm?

What is printed in the minibuffer when you type this into Emacs?

M-x eval-expression RET (executable-find "irony-server") RET
ducbueno commented 2 years ago

The expression prints /usr/bin/irony-server.

Is there a way to make Emacs see it? I mean by something in the configuration.

Sarcasm commented 2 years ago

irony-mode uses executable-find so it should be found:

https://github.com/Sarcasm/irony-mode/blob/b9c64abf81e73860e39ecd82dfa00cca90b53d99/irony.el#L574

What is printed in the minibuffer when you type this into Emacs?

M-x eval-expression RET irony-server-install-prefix RET
ducbueno commented 2 years ago

It seems the install prefix is not defined in my system for some reason. The expression prints Symbol's function definition is void: irony-server-install-prefix.

Sarcasm commented 2 years ago

That's weird, but it can happen if you eval'd this before loading irony-mode, can you double-check irony-mode is actually loaded?

You can force loading by typing this:

M-: (require 'irony) RET

Then check again:

M-: irony-server-install-prefix RET
ducbueno commented 2 years ago

Even after requiring irony the message is still the same.

Sarcasm commented 2 years ago

If you do:

M-x find-library RET irony RET

What do you have around line 166?

https://github.com/Sarcasm/irony-mode/blob/b9c64abf81e73860e39ecd82dfa00cca90b53d99/irony.el#L166-L172

ducbueno commented 2 years ago

My lines 166 through 172 looks exactly like yours.

One thing I noticed, in the definition of irony-server-source-dir there is a line (line 156) that says :package-version '(irony . 1.2.0)). The version of irony that gets installed with apt is 1.4.0. Could this be causing the problem?

Sarcasm commented 2 years ago

What is the path of the file found by M-x find-library RET irony RET?

ducbueno commented 2 years ago

The path is ~/.emacs.d/.local/straight/repos/irony-mode.

Sarcasm commented 2 years ago

Ok, so you have 2 installs. Maybe they conflict, the straight irony.el will use the debian-installed irony-server.

I realize your error checking irony-server-install-prefix was maybe because you added parenthesis around it. Do you really get an error if you type this exactly like so?

M-: (require 'irony) RET
M-: irony-server-install-prefix RET
ducbueno commented 2 years ago

Ah now I got it. My irony-server-install-prefix points to ~/.emacs.d/.local/etc/irony-server/, but this directory doesn't exist.

Sarcasm commented 2 years ago

And the hint to use M-x irony-install-server RET wasn't shown?

ducbueno commented 2 years ago

I just copied the binary that was installed by apt to ~/.emacs.d/.local/etc/irony-server/ and everything seems to work now. Thanks for the help!

If you think this is a good solution I'll close the issue.

Sarcasm commented 2 years ago

If you are satisfied, fine by me, closing. :)

My recommendation would be to either install the Debian package OR from source (ELPA, straight, ...). And, if installing from source, using M-x irony-install-server RET.

sten0 commented 2 years ago

Hi @Sarcasm, I've filed #584 in the hopes that it clarifies this issue for other users. I took the liberty of addressing a potential MELPA+straight.el case that seems to be related to #516, but please let me know if I overstepped in making such a recommendation.

sten0 commented 2 years ago

P.S. and thank you for CCing me :-)