Sarcasm / irony-mode

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

Something wrong with Irony-mode in Windows #457

Open ramsayleung opened 6 years ago

ramsayleung commented 6 years ago

Hey Guillaume, I have read wiki page and I have successfully installed irony-server, but I could not get it work as expected emacs-version :

GNU Emacs 25.3.1 (x86_64-w64-mingw32) of 2017-09-13

irony-server --version output:

irony-server version 1.2.0
clang version 3.8.0 (/repo/sources/clang 1d5b05f1ef9d1b9889ddb5ad946944f224a7ba88) (/repo/sources/llvm 2aebced35905eb3891eba484e4d1902cf7399558)

this is error message:

Irony I/O task: error in callback: (irony-iotask-bad-data [cl-struct-irony-iotask-packaged-task (:start (lambda (process buffer buf-state) (let ((elem (assq buffer (process-get process :unsaved-buffers))) temp-file) (if (eq (cdr elem) buf-state) (irony-iotask-set-result t) (setq temp-file (make-temp-file "irony-unsaved-")) (irony-iotask-put :temp-file temp-file) (irony-iotask-put :buffer-state buf-state) (process-put process :buffer-state buf-state) (with-current-buffer buffer (irony--without-narrowing (let ((write-region-inhibit-fsync t)) (write-region nil nil temp-file nil 0))) (irony--server-send-command "set-unsaved" (irony--get-buffer-path-for-server) temp-file))))) :update irony--server-command-update :finish (lambda (&rest _args) (delete-file (irony-iotask-get :temp-file))) :on-success (lambda (process buffer &rest _args) (let* ((unsaved-buffers (process-get process :unsaved-buffers)) (elem (assq buffer unsaved-buffers)) (buf-state (irony-iotask-get :buffer-state))) (if elem (setcdr elem buf-state) (process-put process :unsaved-buffers (cons (cons buffer buf-state) unsaved-buffers)))))) (#<process Irony> #<buffer test.c> [cl-struct-irony--buffer-state "c:/Users/Administrator/AppData/Local/Temp/test.c" t t 25]) [cl-struct-irony-iotask-result error nil irony-iotask-bad-data (#1 "(error . (file-read-error \"failed to read unsaved buffer\" \"c:/Users/Administrator/AppData/Local/Temp/test.c\" \"c:/Users/ADMINI~1/AppData/Local/Temp/irony-unsaved-25087Ol
\")

;;EOT
")] (:temp-file "c:/Users/ADMINI~1/AppData/Local/Temp/irony-unsaved-25087Ol" :buffer-state [cl-struct-irony--buffer-state "c:/Users/Administrator/AppData/Local/Temp/test.c" t t 25]) [cl-struct-irony-iotask-packaged-task (:start (lambda (file line column compile-options) (apply (function irony--server-send-command) "complete" file line column "--" compile-options)) :update irony--server-command-update) ("c:/Users/Administrator/AppData/Local/Temp/test.c" 1 3 ("-x" "c")) [cl-struct-irony-iotask-result nil nil nil nil] nil [cl-struct-irony-iotask-packaged-task (:start (lambda (prefix style) (irony--server-send-command "candidates" prefix (cl-case style (case-insensitive "case-insensitive") (smart-case "smart-case") (t "exact")))) :update irony--server-query-update) ("inc" case-insensitive) [cl-struct-irony-iotask-result nil nil nil nil] nil nil]]] "(error . (file-read-error \"failed to read unsaved buffer\" \"c:/Users/Administrator/AppData/Local/Temp/test.c\" \"c:/Users/ADMINI~1/AppData/Local/Temp/irony-unsaved-25087Ol
\")

the value of PATH environment value:

D:\msys\mingw64\bin;D:\msys\usr\bin;C:\Users\Administrator\.emacs.d\irony\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_151\bin;C:\Program Files\Java\jdk1.8.0_151\jre\bin;C:\Program Files\Git\cmd;D:\Program Files\apache-maven-3.5.2-bin\apache-maven-3.5.2\bin;C:\Users\Administrator\.bin;C:\cygwin64\bin;D:\Program Files\nodejs\;D:\Program Files (x86)\Yarn\bin;D:\msys\usr\bin;D:\msys\mingw64\bin;C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Scripts\;C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\;C:\Users\Administrator\.cargo\bin;C:\Users\Administrator\AppData\Roaming\npm;C:\Users\Administrator\AppData\Local\Yarn\bin

output of which clang:

d:/msys/usr/bin/clang.exe

my configuration about irony-mode :

(use-package irony
  :ensure t
  :init (progn
      (defun samray/irony-mode-hook ()
        (define-key irony-mode-map [remap completion-at-point] 'counsel-irony)
        (define-key irony-mode-map [remap complete-symbol] 'counsel-irony))
      (add-hook 'c++-mode-hook 'irony-mode)
      (add-hook 'c-mode-hook 'irony-mode)
      (add-hook 'irony-mode-hook 'samray/irony-mode-hook)
      (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
      (when (boundp 'w32-pipe-read-delay)
        (setq w32-pipe-read-delay 0))
      (when (boundp 'w32-pipe-buffer-size)
        (setq w32-pipe-buffer-size (* 64 1024)))
      (setenv "PATH"
          (concat
           "D:\\msys\\mingw64\\bin" ";"
           "D:\\msys\\usr\\bin" ";"
           "C:\\Users\\Administrator\\.emacs.d\\irony\\bin" ";"
           (getenv "PATH")
           ))
      (setq exec-path (append '("d:/msys/mingw64/bin" "d:/msys/usr/bin" "c:/Users/Administrator/.emacs.d/irony/bin")
                  exec-path))

      )
  )

I have tried my best to fix this error, but get nothing, Could you help me out :) ?

3246251196 commented 6 years ago

Have you added the location to your "libclang.dll" into the %PATH% variable?

hjonline commented 3 years ago

i have the same problem: ")) (:temp-file "d:/Personal/Temp/irony-unsaved-qEjeeK" :buffer-state #s(irony--buffer-state "d:/dev/temp/Cpp-Demo-Project-For-Emacs-master/Cpp-Demo-Project-For-Emacs-master/src/main.cpp" t t 51)) #s(irony-iotask-packaged-task (:start (lambda (file line column compile-options) (apply #'irony--server-send-command "complete" file line column "--" compile-options)) :update irony--server-command-update) ("d:/dev/temp/Cpp-Demo-Project-For-Emacs-master/Cpp-Demo-Project-For-Emacs-master/src/main.cpp" 8 3 ("-x" "c++")) #s(irony-iotask-result nil nil nil nil) nil #s(irony-iotask-packaged-task (:start (lambda (prefix style) (irony--server-send-command "candidates" prefix (cl-case style (case-insensitive "case-insensitive") (smart-case "smart-case") (t "exact")))) :update irony--server-query-update) ("h" exact) #s(irony-iotask-result nil nil nil nil) nil nil))) "(error . (file-read-error \"failed to read unsaved buffer\" \"d:/dev/temp/Cpp-Demo-Project-For-Emacs-master/Cpp-Demo-Project-For-Emacs-master/src/main.cpp\" \"d:/Personal/Temp/irony-unsaved-qEjeeK \")

and with M-x shell i run the irony-server --version ,it's ok: irony-server --version irony-server version 1.4.0 clang version 12.0.0

the libclang.dll is in the path variable.

hjonline commented 3 years ago

finally, i solve the problem: it's the msys2 environment which causes the issue. i install the irony-server by hand step 1,entering msys2 shell ,make sure the /mingw64/bin in the very beginning of the $PATH, use "echo $PATH" to check ,and "export PATH=/mingw64/bin:$PATH" to set it. step 2,downlod irony source from github, unzip it, then enter irony's server directory,"mkdir build",then "cd build" step 3,"/usr/bin/cmake .." step 4,install irony-server by hand by using this methon ,the binary irony-server.exe is different to M-x irony-install-server's build, and with the latter , it fails on runtime.