Open vermiculus opened 7 years ago
Where is located your build directory?
Right now irony-mode looks up starting from the current directory and tries a build/
subdirectory.
Where is your compilation database relative to your source file?
Did you use irony-cdb-json-add-compile-commands-path
if it's in a "non-standard" location?
Did you reloaded the file or re-ran irony-cdb-autosetup-compile-options
?
My build directory seems to be .
. The compilation database is a sibling of the source file in the directory tree. I've not configured anything with irony-cdb-json-add-compile-commands-path
. Running irony-cdb-autosetup-compile-options
gives the error
Irony CDB: error in compilation database: (wrong-type-argument stringp nil)
with backtrace
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
string-match("[\\\"]\\| " nil)
#[257 "\301\300\"\203 \302\303\304\305#\302Q\207\207" ["[\\\"]\\| " string-match "\"" replace-regexp-in-string "[\\\"]" "\\\\\\&"] 6 "\n\n(fn STR)"](nil)
mapconcat(#[257 "\301\300\"\203 \302\303\304\305#\302Q\207\207" ["[\\\"]\\| " string-match "\"" replace-regexp-in-string "[\\\"]" "\\\\\\&"] 6 "\n\n(fn STR)"] ("get-compile-options" "/Users/sean/github/emacs-libgit2/" nil) " ")
combine-and-quote-strings(("get-compile-options" "/Users/sean/github/emacs-libgit2/" nil))
irony--send-request("get-compile-options" (irony--sync-request-callback 1) "/Users/sean/github/emacs-libgit2/" nil)
apply(irony--send-request "get-compile-options" (irony--sync-request-callback 1) ("/Users/sean/github/emacs-libgit2/" nil))
irony--send-request-sync("get-compile-options" "/Users/sean/github/emacs-libgit2/" nil)
irony-cdb-libclang--server-exact-flags("/Users/sean/github/emacs-libgit2/compile_commands.json")
irony-cdb-libclang--get-compile-options()
irony-cdb-libclang(get-compile-options)
irony-cdb--autodetect-compile-options()
irony-cdb-autosetup-compile-options()
funcall-interactively(irony-cdb-autosetup-compile-options)
call-interactively(irony-cdb-autosetup-compile-options record nil)
command-execute(irony-cdb-autosetup-compile-options record)
#[257 "\304\305!\203\f \306\307!!\210\307!\211\310\307!\311\")\207" [current-prefix-arg prefix-arg this-command real-this-command featurep smex smex-rank intern command-execute record] 4 "\n\n(fn CMD)"]("irony-cdb-autosetup-compile-options")
ivy-call()
<...>
counsel-M-x()
funcall-interactively(counsel-M-x)
call-interactively(counsel-M-x nil nil)
command-execute(counsel-M-x)
Here is a condensed ls -l
with unrelated files removed:
/Users/sean/github/emacs-libgit2:
total used in directory 1740 available 4291560854
drwxr-xr-x 27 sean staff 918 Oct 15 10:52 .
drwxr-xr-x 38 sean staff 1292 Oct 12 23:37 ..
drwxr-xr-x 16 sean staff 544 Oct 15 10:52 .git
-rw-r--r-- 1 sean staff 18700 Oct 15 10:51 CMakeCache.txt
drwxr-xr-x 17 sean staff 578 Oct 15 10:51 CMakeFiles
-rw-r--r-- 1 sean staff 859 Sep 20 12:23 CMakeLists.txt
-rw-r--r-- 1 sean staff 7658 Oct 15 10:51 Makefile
-rw-r--r-- 1 sean staff 1412 Sep 20 12:25 cmake_install.cmake
-rw-r--r-- 1 sean staff 121787 Oct 15 10:51 compile_commands.json
drwxr-x--- 3 sean staff 102 Sep 20 12:25 include
drwxr-xr-x 38 sean staff 1292 Oct 15 10:51 libgit2
-rw-r--r-- 1 sean staff 2548 Oct 15 10:52 libgit2-core.c
-rw-r--r-- 1 sean staff 535 Oct 15 10:13 libgit2.el
drwxr-xr-x 8 sean staff 272 Oct 15 10:13 test
-rw-r--r-- 1 sean staff 19 Oct 15 10:22 test-it.el
drwxr-xr-x 5 sean staff 170 Sep 20 12:23 test2
I've honestly not done much; to reproduce my directory completely, you should be able to
git clone git@github.com:ksjogo/emacs-libgit2.git
cd emacs-libgit2
git submodule update --init --recursive
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
make
However, after running irony-cdb-autosetup-compile-options
(even with it producing an error), irony-cdb-menu
now shows a database.
It looks like the error appears because buffer-file-name
is nil
.
Can you show the output of:
C-h v buffer-file-name RET
I was in a magit-status buffer, so that explains that. Where should I ideally run it from?
The suggested default configuration (https://github.com/Sarcasm/irony-mode/tree/4b63b809c9643b90d396cbcc1ed0a53659888f4d#configuration) will run it as a hook when you open a C/C++ file.
It should be run in a buffer where irony-mode is active.
However, don't close this issue. We should support nil buffer-file-name
, it happens when a new file has been created and is not yet saved to disk for example.
Don't worry, I won't close the issue. All unhandled errors are usually not ideal :)
One extra piece of information, though – when I run it from an irony-mode C buffer, emacs appears to hang:
Debugger entered--Lisp error: (quit)
irony--send-request-sync("get-compile-options" "/Users/sean/github/emacs-libgit2/" "/Users/sean/github/emacs-libgit2/libgit2-core.c")
irony-cdb-libclang--server-exact-flags("/Users/sean/github/emacs-libgit2/compile_commands.json")
irony-cdb-libclang--get-compile-options()
irony-cdb-libclang(get-compile-options)
irony-cdb--autodetect-compile-options()
irony-cdb-autosetup-compile-options()
funcall-interactively(irony-cdb-autosetup-compile-options)
call-interactively(irony-cdb-autosetup-compile-options record nil)
Does irony-server works?
~/.emacs.d/irony/bin/irony-server --version
irony-server version 0.2.0
clang version 3.8.1 (tags/RELEASE_381/final)
Does it happen even after you restart irony-server/emacs? Do you see anything in the log file in /tmp/irony.XXX?
/tmp/irony.XXX
does not exist.
Restarting emacs did the trick… strange. Thanks for your help!
I'll leave this issue open to gracefully handle non-file buffers.
I met the same issue, but can't solve it by restarting emacs, the /tmp/irony.XXX
is exist, saw message in that file:
(
(("/app/gcc/5.3.0/bin/g++" "-DCLANG_BUILTIN_HEADERS_DIR=\"/app/clang/3.8.0/lib/clang/3.8.0/include\"" "-fno-exceptions" "-O3" "-DNDEBUG" "-I/app/clang/3.8.0/include" "-I/local/workspace/irony-mode/server/src" "-std=c++11" "-Wall" "-Wextra" "-o" "CMakeFiles/irony-server.dir/Command.cpp.o" "-c" "/local/workspace/irony-mode/server/src/Command.cpp" ) . "/local/workspace/irony-mode/server/build/src")
)
;;EOT
The server process was started by emacs:
robin 2767 2082 0 15:29 ? 00:00:00 /bin/tcsh -c /home/robin/.emacs.d/irony/bin/irony-server -i 2> /tmp/irony.2017-04-05_15h-29m-54s.log
robin 2863 2767 0 15:29 ? 00:00:00 /home/robin/.emacs.d/irony/bin/irony-server -i 2
my irony server version is:
irony-server version 0.2.2-cvs
clang version 3.8.0 (tags/RELEASE_380/final)
It works fine if i run command manually, but it hangs at irony--send-request-sync
.
Fine means not hang at terminal, output same as the /tmp/irony.XXX
Any suggestion?
The issue comes from tcsh, see https://github.com/Sarcasm/irony-mode/issues/299
works fine after change to be bash
This is a separate thread to resolve my follow-up question in #167 – clearly I'm doing something wrong, but I can't find further documentation that explains what this could be.
This is the first time I've seriously tried to make irony-mode work; I've played with it before with no significant success, but it will be necessary for my current project.
When I run
irony-cdb-menu
from a directory where a non-empty./compile_commands.json
exists (as created bycmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
, it comes up empty: