Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Wrong type argument: hash-table-p, nil" when opening non-CMake files #143

Closed
cyrus-and opened this issue Dec 8, 2017 · 20 comments
Closed

Comments

@cyrus-and
Copy link
Contributor

Just open a standalone C file and the following happens:

cmake-ide [Fri Dec  8 22:04:56 2017]: Making directory /tmp/cmakeyTKBVQ
cmake-ide [Fri Dec  8 22:04:57 2017]: Starting rdm server
cmake-ide [Fri Dec  8 22:04:57 2017]: Running cmake for src path /home/cyrus/tmp/ in build path /tmp/cmakeyTKBVQ/
cmake-ide [Fri Dec  8 22:04:57 2017]: Finished running CMake
cmake-ide [Fri Dec  8 22:04:57 2017]: Non-existent compilation DB file /tmp/cmakeyTKBVQ/compile_commands.json
error in process sentinel: cmake-ide--idb-file-to-obj: Wrong type argument: hash-table-p, nil
error in process sentinel: Wrong type argument: hash-table-p, nil

IMHO cmake-ide should do nothing at all (especially starting rdm and creating build directories) if it cannot find a suitable environment first.

This seems related to: #93 and #111.


Relevant configuration:

(require 'rtags)
(cmake-ide-setup)
(rtags-enable-standard-keybindings)
  • GNU Emacs 26.0.90
  • cmake-ide from MELPA
  • Debian GNU/Linux 9
@darcylee
Copy link

I also encountered the same problem.

@dlyr
Copy link
Contributor

dlyr commented Dec 11, 2017

Could you test with my fork of cmake-ide ? I have maybe fixed this ...
It's the branch wip_project_key here
https://github.com/dlyr/cmake-ide/tree/wip_project_key

@cyrus-and
Copy link
Contributor Author

Alright this issue has been introduced in 99bfce8 apparently and @dlyr your PR seems to fix it, although a bunch of weird messages are logged:

cmake-ide [Mon Dec 11 18:04:05 2017]: locate cmakelists new-dir [nil]
cmake-ide [Mon Dec 11 18:04:05 2017]: locate-project-dir : [nil][nil]
cmake-ide [Mon Dec 11 18:04:05 2017]: Current project is not a cmake project
cmake-ide [Mon Dec 11 18:04:05 2017]: Not a cmake project
cmake-ide [Mon Dec 11 18:04:05 2017]: puthash for cmake-ide [Mon Dec 11 18:04:05 2017]: Not a cmake project /var/folders/jb/b_c1572j103c989nd69w6sch0000gn/T/cmakeBM8YtP
cmake-ide [Mon Dec 11 18:04:05 2017]: locate cmakelists new-dir [nil]
cmake-ide [Mon Dec 11 18:04:05 2017]: locate-project-dir : [nil][nil]
cmake-ide [Mon Dec 11 18:04:05 2017]: Current project is not a cmake project
cmake-ide [Mon Dec 11 18:04:05 2017]: Making directory /var/folders/jb/b_c1572j103c989nd69w6sch0000gn/T/cmakeBM8YtP
cmake-ide [Mon Dec 11 18:04:05 2017]: locate cmakelists new-dir [nil] [2 times]
cmake-ide [Mon Dec 11 18:04:05 2017]: locate-project-dir : [nil][nil]
cmake-ide [Mon Dec 11 18:04:05 2017]: Current project is not a cmake project
cmake-ide [Mon Dec 11 18:04:05 2017]: Not a cmake project
cmake-ide [Mon Dec 11 18:04:05 2017]: locate cmakelists new-dir [nil]
cmake-ide [Mon Dec 11 18:04:05 2017]: locate-project-dir : [nil][nil]
cmake-ide [Mon Dec 11 18:04:05 2017]: Current project is not a cmake project
cmake-ide [Mon Dec 11 18:04:05 2017]: locate cmakelists new-dir [nil] [2 times]
cmake-ide [Mon Dec 11 18:04:05 2017]: locate-project-dir : [nil][nil]
cmake-ide [Mon Dec 11 18:04:05 2017]: Current project is not a cmake project
cmake-ide [Mon Dec 11 18:04:05 2017]: Not a cmake project
cmake-ide [Mon Dec 11 18:04:05 2017]: locate cmakelists new-dir [nil]
cmake-ide [Mon Dec 11 18:04:05 2017]: locate-project-dir : [nil][nil]
cmake-ide [Mon Dec 11 18:04:05 2017]: Current project is not a cmake project
cmake-ide [Mon Dec 11 18:04:05 2017]: locate cmakelists new-dir [nil]
cmake-ide [Mon Dec 11 18:04:05 2017]: locate-project-dir : [nil][nil]
cmake-ide [Mon Dec 11 18:04:05 2017]: Current project is not a cmake project

Plus this happens when I rtags-find-symbol-at-point:

error in process sentinel: not: Symbol’s function definition is void: string-empty-p
error in process sentinel: Symbol’s function definition is void: string-empty-p

But that's another issue.

@dlyr
Copy link
Contributor

dlyr commented Dec 11, 2017

Yeah the locate message are for debug purpose (I will remove them soon I hope).
the Current projet is not a cmake project will stay to inform that cmake-ide functionalities are not available.
I will check the rtag thing ;)

@dlyr
Copy link
Contributor

dlyr commented Dec 11, 2017

By the way what did you expect from rtags ?
Mine say
No buffer named "Can't seem to connect to server (/run/user/1000/rdm.socket)Can't seem to connect to server (/run/user/1000/rdm.socket)Can't seem to connect to server (/run/user/1000/rdm.socket)
"
And if a run rdm myself
I have No buffer named "[A directory of a former project]/Not indexed
"

@cyrus-and
Copy link
Contributor Author

To jump to the symbol under the point, which works indeed but then that error appears.

You need to install rtags both the program and the Emacs package.

@dlyr
Copy link
Contributor

dlyr commented Dec 11, 2017

(rtags works well for me with an cmake-ide project)
Do you generate a compile-commands.json ?

@cyrus-and
Copy link
Contributor Author

@dlyr it's performed automatically and it works with master.

Here's the stack trace:

Debugger entered--Lisp error: (void-function string-empty-p)
  (string-empty-p (cmake-ide--buffer-string buffer))
  (not (string-empty-p (cmake-ide--buffer-string buffer)))
  (and (not (string-empty-p (cmake-ide--buffer-string buffer))) (not cmake-ide-header-no-flags))
  (if (and (not (string-empty-p (cmake-ide--buffer-string buffer))) (not cmake-ide-header-no-flags)) (progn (cond (cmake-ide-try-unique-compiler-flags-for-headers (cmake-ide--hdr-try-unique-compiler-flags idb buffer sys-includes)) ((cmake-ide--hdr-ask-ninja-and-make idb buffer sys-includes) t) (t (cmake-ide--hdr-legacy idb buffer sys-includes)))))
  cmake-ide--set-flags-for-hdr-file(#<hash-table equal 14/65 0x16d04e5> #<buffer handler.h> nil)
  (if (cmake-ide--is-src-file file-name) (cmake-ide--set-flags-for-src-file file-params buffer sys-includes) (cmake-ide--set-flags-for-hdr-file idb buffer (cmake-ide--flags-to-sys-includes hdr-flags)))
  (let* ((file-name (buffer-file-name buffer)) (file-params (cmake-ide--idb-file-to-obj idb file-name)) (sys-includes (cmake-ide--params-to-sys-includes file-params)) (commands (cmake-ide--idb-all-commands idb)) (hdr-flags (cmake-ide--commands-to-hdr-flags commands))) (cmake-ide--message "Setting flags for file %s" file-name) (if (cmake-ide--is-src-file file-name) (cmake-ide--set-flags-for-src-file file-params buffer sys-includes) (cmake-ide--set-flags-for-hdr-file idb buffer (cmake-ide--flags-to-sys-includes hdr-flags))))
  cmake-ide--set-flags-for-file(#<hash-table equal 14/65 0x16d04e5> #<buffer handler.h>)
  (closure ((idb . #<hash-table equal 14/65 0x16d04e5>) cmake-ide--semantic-system-include t) (x) (cmake-ide--set-flags-for-file idb x))(#<buffer handler.h>)
  mapc((closure ((idb . #<hash-table equal 14/65 0x16d04e5>) cmake-ide--semantic-system-include t) (x) (cmake-ide--set-flags-for-file idb x)) (#<buffer handler.h>))
  (let* ((idb (cmake-ide--cdb-json-file-to-idb)) (set-flags (function (lambda (x) (cmake-ide--set-flags-for-file idb x))))) (mapc set-flags cmake-ide--src-buffers) (mapc set-flags cmake-ide--hdr-buffers) (setq cmake-ide--src-buffers nil cmake-ide--hdr-buffers nil) (cmake-ide--run-rc))
  cmake-ide--on-cmake-finished()
  (closure (cmake-ide--semantic-system-include t) (_process _event) (cmake-ide--message "Finished running CMake") (cmake-ide--on-cmake-finished))(#<process cmake> "finished\n")

(Feel free to move this thread to a new issue if you want.)

@dlyr
Copy link
Contributor

dlyr commented Dec 11, 2017

hum, I don't know and it work on my project, could you post a minimal example to reproduce the bug ?
string-empty-p is defined in subr (you need to include/install subr-x somewhere)
but that's strang it works on master which also use this function ...

@cyrus-and
Copy link
Contributor Author

  1. start Emacs with env HOME=/tmp/ emacs -Q;

  2. paste the following in the scratch buffer then M-x eval-buffer:

    (package-initialize)
    
    (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
    
    (package-refresh-contents)
    
    (package-install-file "/path/to/your/cmake-ide.el")
    (package-install 'rtags)
    
    (require 'rtags)
    (cmake-ide-setup)
  3. clone this repo somewhere;

  4. back to Emacs open /path/to/repo/src/main.c;

  5. move the point on line 7 over zz_handler;

  6. M-x rtags-find-symbol-at-point the file handler.h is visited and the error triggers.

I just noticed that this happens the first time only.

dlyr added a commit to dlyr/cmake-ide that referenced this issue Dec 12, 2017
bad fix for atilaneves#55 atilaneves#143
By the way there is still warning that should raise other issues :
cmake-ide.el:1147:1:Warning: the following functions are not known to be
    defined: rtags-executable-find, string-empty-p,
    irony-cdb-json-add-compile-commands-path, flycheck-clear, subseq, distance
@dlyr
Copy link
Contributor

dlyr commented Dec 12, 2017

if you add
(require 'subr-x)
above (cmake-ide-setup) it works right ?
This should definitively be setup in cmake-ide (see #55 #127)
I have tested something here to load subr-x but if fails try to define empty-string-p. Since I quite new to emacs-lisp, it might not be the right way to do this.

@cyrus-and
Copy link
Contributor Author

it works right ?

Yeps.

@dlyr
Copy link
Contributor

dlyr commented Dec 12, 2017 via email

@juergenhoetzel
Copy link
Contributor

error in process sentinel: Wrong type argument: hash-table-p, nil

Just for the record: This also happens if you use in-source-build. I.e. CMakeCache.txt is already existent in the source dir. So compile_commands.json is also generated in the source dir.

@cyrus-and
Copy link
Contributor Author

I kind of lost track of this... but it seems that the original error ("Wrong type argument: hash-table-p, nil") does not happen anymore. Can you confirm?

@martinxyz
Copy link
Contributor

@juergenhoetzel See PR #185 for the problem that happens if a build exists in the source directory.

@skrat
Copy link

skrat commented Jun 12, 2019

This is still a problem when following the installation and usage manual. My impression so far from using rtags + cmake-ide is that it works less than half of the time and every almost every time I open a source file, I get this error because it can't find the compilation DB, so why doesn't it just fail silently and let me work?

@atilaneves
Copy link
Owner

@skrat I'd fix it if I knew what was going on. I haven't been able to reproduce it.

@skrat
Copy link

skrat commented Jun 14, 2019

@atilaneves I'm more than happy to assist, I'm on Emacs 27, this is the stack trace:

Debugger entered--Lisp error: (wrong-type-argument hash-table-p nil)
  gethash("/home/skrat/Workspace/xxx/lightmapper/src/li..." nil)
  cide--idb-file-to-obj(nil "/home/skrat/Workspace/xxx/lightmapper/src/li...")
  cide--set-flags-for-file(nil #<buffer lightmapper.cpp>)
  #f(compiled-function (x) #<bytecode 0x158d22f1f4e9>)(#<buffer lightmapper.cpp>)
  mapc(#f(compiled-function (x) #<bytecode 0x158d22f1f4e9>) (#<buffer lightmapper.cpp>))
  cide--on-cmake-finished()
  cmake-ide-load-db()
  funcall-interactively(cmake-ide-load-db)
  call-interactively(cmake-ide-load-db record nil)
  command-execute(cmake-ide-load-db record)
  #f(compiled-function (cmd) #<bytecode 0x158d228f8d6d>)("cmake-ide-load-db")
  ivy-call()
  ivy-read("M-x " ("cmake-ide-load-db" "diff-hl-mode" "c++-mode" "rtags-restart-process" "rtags-find-symbol-at-point" "man" "calc" "cmake-ide-compile" "counsel-package" "eldoc-mode" "package-install" "package-delete" "counsel-unicode-char" "mu4e" "which-key-show-major-mode" "tide-mode" "package-refresh-contents" "ielm" "list-packages" "describe-function" "rtags-find-references" "load-theme" "eglot" "ibuffer" "irony-mode" "insert-char" "ivy-rich-mode" "paredit-mode" "customize-variable" "add-dir-local-variable" "eshell" "irony-eldoc" "customize-group" "describe-variable" "imenu" "tide-setup" "describe-mode" "form-feed-mode" "counsel-ibuffer" "rtags-is-running" "package-autoremove" "irony-install-server" "rainbow-delimiters-mode" "smex" "swiper" "csharp-mode" "company-mode" "delete-window" "flycheck-mode" "auto-fill-mode" ...) :predicate nil :require-match t :history counsel-M-x-history :action #f(compiled-function (cmd) #<bytecode 0x158d228f8d6d>) :sort nil :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  counsel-M-x()
  funcall-interactively(counsel-M-x)
  call-interactively(counsel-M-x nil nil)
  command-execute(counsel-M-x)

@atilaneves
Copy link
Owner

@skrat Thanks, that helps but I still don't know how to reproduce it. It'd be easier if someone who can would debug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants