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

"No compilation database in use" even after adding it explicitly #575

Closed jlagarespo closed 3 years ago

jlagarespo commented 3 years ago

I'm having a lot of trouble trying to get irony to work. So I have a project in /home/moonsheep/src/rabbit3d/, with a JSON compilation database generated using premake5 (compile_commands/compile_commands.json). I used irony-cdb-json-add-compile-commands-path and I added the compile_commands directory. Then it prompted me for a json file in said directory, and I chose compile_commands.json. I get no errors, and in fact no output at all. If I run irony-cdb-json-select I just get a prompt with a list with 0 items in it. Then I ran irony-cdb-autosetup-compile-options (again, with no output from that command) but it doesn't look like it's using it at all. If I run irony-cdb-menu I just get a message that says "No compilation database in use" and a prompt that only allows me to "q to quit".

I think it is worth noting that when I first ran irony-cdb-add-compile-commands-path it complained that the file /home/moonsheep/.emacs.d/.local/etc/irony/cdb-json-projects didn't exist. I just created an empty file and hoped it would work. When I ran the command again it got populated with the following:

;; -*- emacs-lisp -*-
;;
;; JSON Compilation Database project list.
;;
;; File auto-generated by irony-cdb-json.
;;
(("/home/moonsheep/src/rabbit3d/compile_commands/" . "/home/moonsheep/src/rabbit3d/compile_commands/compile_commands.json"))

which looks pretty alright to me. This is how I configure irony:

(use-package! irony-mode
  :hook
  (c++-mode-hook . irony-mode)
  (c-mode-hook . irony-mode)
  (objc-mode-hook . irony-mode)
  (irony-mode-hook . irony-cdb-autosetup-compile-options))

(use-package! flycheck-irony
  :hook
  (flycheck-mode-hook . #'flycheck-irony-setup))

(Please note that I use doom emacs, hence the exclamation mark in use-package!) For now I'm just interested in flycheck, I might try company later.

Is there something I am doing wrong? My elisp-fu is not exactly great. Many thanks in advance :)

jlagarespo commented 3 years ago

I figured it out. I thought the first option with irony-cdb-add-compile-commands-path was the compile_commands directory, but it is in fact the working directory of the entire project. It works very nicely now :)