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

C-x C-f (counsel-find-file) open typescript files hang need 'C-g' to reopen again #580

Closed
lvii opened this issue May 14, 2018 · 24 comments
Closed

Comments

@lvii
Copy link

lvii commented May 14, 2018

Hi,

I used emacs 25.3.1 under Fedora 28.

When I opened angular typescript code .ts files with C-x C-f (counsel-find-file) , minibuffer frozen on opening file path. I have to use C-g to close minibuffer and reopen the file again with C-x C-f (counsel-find-file).

C-x C-f (counsel-find-file) opened .html, .sh, .md flies only need once, minibuffer would NOT hang.

@lvii
Copy link
Author

lvii commented May 15, 2018

I run emacs in docker and the code base dir was mounted by docker.

I run emacs without purcell-emacs.d and install counsel and ng2-mode packages manually. There would be NO problem.

When I switch back purcell-emacs.d config and with M-x toggle-debug-on-quit RET.

C-x C-f opened file hang without any timeout, here was the screenshot.

Imgur

C-g showed the debug messages below: http://ix.io/1alV

Debugger entered--Lisp error: (quit)
  file-directory-p("/node_modules/.bin/")
  add-node-modules-path()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook typescript-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook typescript-mode-hook))
  run-mode-hooks(typescript-mode-hook)
  typescript-mode()
  set-auto-mode-0(typescript-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer app.module.ts> "/home/py/code/django/zerone/angular/zerone/src/app/app.module.ts" nil nil "/home/py/code/django/zerone/angular/zerone/src/app/app.module.ts" (1076405032 2050))
  find-file-noselect("/home/py/code/django/zerone/angular/zerone/src/app/app.module.ts" nil nil nil)
  find-file("/home/py/code/django/zerone/angular/zerone/src/app/app.module.ts")
  counsel-find-file-action("/home/py/code/django/zerone/angular/zerone/src/app/app.module.ts")
  ivy-call()
  #[642 "\306�\307\"A@\306�\310\"A@\306�\311\"A@\306�\312\"A@\306�\313\"A@\306��\314\"A@\306��\315\"A@\306��\316\"A@\306�	\317\"A@\306�\n\320\"A@\306��\321\"A@C\306�\f\322\"A@\306�
\323\"A@\306��\324\"A@\306��\325\"A@��\211\203\222�\211@\326>\203z�\211AA\262�\202g�\327��>A@\203\211�\330\262�\202g�\331\332�@\"\210\202g�\210\333\334\335�\336\"\335�	\"\335���\"#!\211\203\322�\337��!\203\274�\340\341��\342BB�BB\202\320���\204\311�\340\343�BB\202\320�\333\334���\"!\262�\210\335\n�\"\211\203\n�\330�\211\211\203��\211@\211\344\232\203\361�\211�B�\202\377�\211A\204\377�\211@�@ D�B��A\266\202\202\336�\210\202\f�\345�\210\346 \205��\f\335
�\206\"�\337��!\205\"���\"\347 ?\205:��@\206:���A\236\2069�\336�A\236A�\203S�\350��B\"\211\203L�\211A\202N��C\262�\202U��C��@��D\351\352��������������������\353 \354 p\330����\242���������E��\330�&&��\355\f!\210\356\357\360\361\351�
!\362\"\363$\216\364\330C\211\356\357\365\361\351����\"\366\"\367$\240\210\356\357\370\361\351�!\371\"\367$\216\372\373�\242\"\210��\206\313�\374���F���G��C\375 \203\337�\330\202\352��H\204\350�\376\202\352��H�H�I\203 ��JG\340U\203 �\f\357H�K>\204
�\377\201Q�\201R�\fD\"\210\f\211\201S��J@I\266�\201T��L\202H�\201U���\f\357H�K>\2049�\377\201Q�\201R�\fD\"\210\f\363H\201V����M\"\330�%\210�L\201T�=\203\223��N\203r�\f\357H�K>\204j�\377\201Q�\201R�\fD\"\210\f\201S�H\202t��O\211\201W�\232\204\222��\201X��\201Y��P#\201Z���JA\"BL\210\210\f\357H�K>\204\247�\377\201Q�\201R�\fD\"\210\f\201S�H,\262�)\266\202)\201[� \210\f\357H�K>\204\314�\377\201Q�\201R�\fD\"\210\f\201S�HG\357V\203\372�\201\\�\357\340\201]�\f\357H�K>\204\363�\377\201Q�\201R�\fD\"\210\f\201S�H$\210*\266\204\207" [ivy--actions-list this-command ivy--sources-list ivy--extra-candidates ivy-last ivy--display-transformers-list plist-member :predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller (:predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller :allow-other-keys) :allow-other-keys nil error "Keyword argument %s not one of (:predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller)" delete-dups append plist-get t functionp 1 "o" ("default") ("o" identity "default") (original-source) ((original-source)) active-minibuffer-window window-minibuffer-p assoc vector cl-struct-ivy-state selected-frame selected-window ivy--reset-state make-byte-code 0 "\304\305\306\"\210\307\310!\311�!\203��\211 \210\210\300	\312H\n>\204\"�\313\314\315	D\"\210	\316H\240\203-�\300\242 \210�\317=?\2056�\320 \207" vconcat ...] 48 ("/root/.emacs.d/elpa-25.3/ivy-20180513.1037/ivy.elc" . 75464)]("Find file: " read-file-name-internal :matcher counsel--find-file-matcher :initial-input nil :action counsel-find-file-action :preselect nil :require-match confirm-after-completion :history file-name-history :keymap (keymap (27 keymap (25 . counsel-yank-directory)) (C-backspace . counsel-up-directory) (67108991 . counsel-up-directory)) :caller counsel-find-file)
  apply(#[642 "\306�\307\"A@\306�\310\"A@\306�\311\"A@\306�\312\"A@\306�\313\"A@\306��\314\"A@\306��\315\"A@\306��\316\"A@\306�	\317\"A@\306�\n\320\"A@\306��\321\"A@C\306�\f\322\"A@\306�
\323\"A@\306��\324\"A@\306��\325\"A@��\211\203\222�\211@\326>\203z�\211AA\262�\202g�\327��>A@\203\211�\330\262�\202g�\331\332�@\"\210\202g�\210\333\334\335�\336\"\335�	\"\335���\"#!\211\203\322�\337��!\203\274�\340\341��\342BB�BB\202\320���\204\311�\340\343�BB\202\320�\333\334���\"!\262�\210\335\n�\"\211\203\n�\330�\211\211\203��\211@\211\344\232\203\361�\211�B�\202\377�\211A\204\377�\211@�@ D�B��A\266\202\202\336�\210\202\f�\345�\210\346 \205��\f\335
�\206\"�\337��!\205\"���\"\347 ?\205:��@\206:���A\236\2069�\336�A\236A�\203S�\350��B\"\211\203L�\211A\202N��C\262�\202U��C��@��D\351\352��������������������\353 \354 p\330����\242���������E��\330�&&��\355\f!\210\356\357\360\361\351�
!\362\"\363$\216\364\330C\211\356\357\365\361\351����\"\366\"\367$\240\210\356\357\370\361\351�!\371\"\367$\216\372\373�\242\"\210��\206\313�\374���F���G��C\375 \203\337�\330\202\352��H\204\350�\376\202\352��H�H�I\203 ��JG\340U\203 �\f\357H�K>\204
�\377\201Q�\201R�\fD\"\210\f\211\201S��J@I\266�\201T��L\202H�\201U���\f\357H�K>\2049�\377\201Q�\201R�\fD\"\210\f\363H\201V����M\"\330�%\210�L\201T�=\203\223��N\203r�\f\357H�K>\204j�\377\201Q�\201R�\fD\"\210\f\201S�H\202t��O\211\201W�\232\204\222��\201X��\201Y��P#\201Z���JA\"BL\210\210\f\357H�K>\204\247�\377\201Q�\201R�\fD\"\210\f\201S�H,\262�)\266\202)\201[� \210\f\357H�K>\204\314�\377\201Q�\201R�\fD\"\210\f\201S�HG\357V\203\372�\201\\�\357\340\201]�\f\357H�K>\204\363�\377\201Q�\201R�\fD\"\210\f\201S�H$\210*\266\204\207" [ivy--actions-list this-command ivy--sources-list ivy--extra-candidates ivy-last ivy--display-transformers-list plist-member :predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller (:predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller :allow-other-keys) :allow-other-keys nil error "Keyword argument %s not one of (:predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller)" delete-dups append plist-get t functionp 1 "o" ("default") ("o" identity "default") (original-source) ((original-source)) active-minibuffer-window window-minibuffer-p assoc vector cl-struct-ivy-state selected-frame selected-window ivy--reset-state make-byte-code 0 "\304\305\306\"\210\307\310!\311�!\203��\211 \210\210\300	\312H\n>\204\"�\313\314\315	D\"\210	\316H\240\203-�\300\242 \210�\317=?\2056�\320 \207" vconcat ...] 48 ("/root/.emacs.d/elpa-25.3/ivy-20180513.1037/ivy.elc" . 75464)] ("Find file: " read-file-name-internal :matcher counsel--find-file-matcher :initial-input nil :action counsel-find-file-action :preselect nil :require-match confirm-after-completion :history file-name-history :keymap (keymap (27 keymap (25 . counsel-yank-directory)) (C-backspace . counsel-up-directory) (67108991 . counsel-up-directory)) :caller counsel-find-file))
  ivy-historian--nadvice/ivy-read(#[642 "\306�\307\"A@\306�\310\"A@\306�\311\"A@\306�\312\"A@\306�\313\"A@\306��\314\"A@\306��\315\"A@\306��\316\"A@\306�	\317\"A@\306�\n\320\"A@\306��\321\"A@C\306�\f\322\"A@\306�
\323\"A@\306��\324\"A@\306��\325\"A@��\211\203\222�\211@\326>\203z�\211AA\262�\202g�\327��>A@\203\211�\330\262�\202g�\331\332�@\"\210\202g�\210\333\334\335�\336\"\335�	\"\335���\"#!\211\203\322�\337��!\203\274�\340\341��\342BB�BB\202\320���\204\311�\340\343�BB\202\320�\333\334���\"!\262�\210\335\n�\"\211\203\n�\330�\211\211\203��\211@\211\344\232\203\361�\211�B�\202\377�\211A\204\377�\211@�@ D�B��A\266\202\202\336�\210\202\f�\345�\210\346 \205��\f\335
�\206\"�\337��!\205\"���\"\347 ?\205:��@\206:���A\236\2069�\336�A\236A�\203S�\350��B\"\211\203L�\211A\202N��C\262�\202U��C��@��D\351\352��������������������\353 \354 p\330����\242���������E��\330�&&��\355\f!\210\356\357\360\361\351�
!\362\"\363$\216\364\330C\211\356\357\365\361\351����\"\366\"\367$\240\210\356\357\370\361\351�!\371\"\367$\216\372\373�\242\"\210��\206\313�\374���F���G��C\375 \203\337�\330\202\352��H\204\350�\376\202\352��H�H�I\203 ��JG\340U\203 �\f\357H�K>\204
�\377\201Q�\201R�\fD\"\210\f\211\201S��J@I\266�\201T��L\202H�\201U���\f\357H�K>\2049�\377\201Q�\201R�\fD\"\210\f\363H\201V����M\"\330�%\210�L\201T�=\203\223��N\203r�\f\357H�K>\204j�\377\201Q�\201R�\fD\"\210\f\201S�H\202t��O\211\201W�\232\204\222��\201X��\201Y��P#\201Z���JA\"BL\210\210\f\357H�K>\204\247�\377\201Q�\201R�\fD\"\210\f\201S�H,\262�)\266\202)\201[� \210\f\357H�K>\204\314�\377\201Q�\201R�\fD\"\210\f\201S�HG\357V\203\372�\201\\�\357\340\201]�\f\357H�K>\204\363�\377\201Q�\201R�\fD\"\210\f\201S�H$\210*\266\204\207" [ivy--actions-list this-command ivy--sources-list ivy--extra-candidates ivy-last ivy--display-transformers-list plist-member :predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller (:predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller :allow-other-keys) :allow-other-keys nil error "Keyword argument %s not one of (:predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller)" delete-dups append plist-get t functionp 1 "o" ("default") ("o" identity "default") (original-source) ((original-source)) active-minibuffer-window window-minibuffer-p assoc vector cl-struct-ivy-state selected-frame selected-window ivy--reset-state make-byte-code 0 "\304\305\306\"\210\307\310!\311�!\203��\211 \210\210\300	\312H\n>\204\"�\313\314\315	D\"\210	\316H\240\203-�\300\242 \210�\317=?\2056�\320 \207" vconcat ...] 48 ("/root/.emacs.d/elpa-25.3/ivy-20180513.1037/ivy.elc" . 75464)] "Find file: " read-file-name-internal :matcher counsel--find-file-matcher :initial-input nil :action counsel-find-file-action :preselect nil :require-match confirm-after-completion :history file-name-history :keymap (keymap (27 keymap (25 . counsel-yank-directory)) (C-backspace . counsel-up-directory) (67108991 . counsel-up-directory)) :caller counsel-find-file)
  apply(ivy-historian--nadvice/ivy-read #[642 "\306�\307\"A@\306�\310\"A@\306�\311\"A@\306�\312\"A@\306�\313\"A@\306��\314\"A@\306��\315\"A@\306��\316\"A@\306�	\317\"A@\306�\n\320\"A@\306��\321\"A@C\306�\f\322\"A@\306�
\323\"A@\306��\324\"A@\306��\325\"A@��\211\203\222�\211@\326>\203z�\211AA\262�\202g�\327��>A@\203\211�\330\262�\202g�\331\332�@\"\210\202g�\210\333\334\335�\336\"\335�	\"\335���\"#!\211\203\322�\337��!\203\274�\340\341��\342BB�BB\202\320���\204\311�\340\343�BB\202\320�\333\334���\"!\262�\210\335\n�\"\211\203\n�\330�\211\211\203��\211@\211\344\232\203\361�\211�B�\202\377�\211A\204\377�\211@�@ D�B��A\266\202\202\336�\210\202\f�\345�\210\346 \205��\f\335
�\206\"�\337��!\205\"���\"\347 ?\205:��@\206:���A\236\2069�\336�A\236A�\203S�\350��B\"\211\203L�\211A\202N��C\262�\202U��C��@��D\351\352��������������������\353 \354 p\330����\242���������E��\330�&&��\355\f!\210\356\357\360\361\351�
!\362\"\363$\216\364\330C\211\356\357\365\361\351����\"\366\"\367$\240\210\356\357\370\361\351�!\371\"\367$\216\372\373�\242\"\210��\206\313�\374���F���G��C\375 \203\337�\330\202\352��H\204\350�\376\202\352��H�H�I\203 ��JG\340U\203 �\f\357H�K>\204
�\377\201Q�\201R�\fD\"\210\f\211\201S��J@I\266�\201T��L\202H�\201U���\f\357H�K>\2049�\377\201Q�\201R�\fD\"\210\f\363H\201V����M\"\330�%\210�L\201T�=\203\223��N\203r�\f\357H�K>\204j�\377\201Q�\201R�\fD\"\210\f\201S�H\202t��O\211\201W�\232\204\222��\201X��\201Y��P#\201Z���JA\"BL\210\210\f\357H�K>\204\247�\377\201Q�\201R�\fD\"\210\f\201S�H,\262�)\266\202)\201[� \210\f\357H�K>\204\314�\377\201Q�\201R�\fD\"\210\f\201S�HG\357V\203\372�\201\\�\357\340\201]�\f\357H�K>\204\363�\377\201Q�\201R�\fD\"\210\f\201S�H$\210*\266\204\207" [ivy--actions-list this-command ivy--sources-list ivy--extra-candidates ivy-last ivy--display-transformers-list plist-member :predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller (:predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller :allow-other-keys) :allow-other-keys nil error "Keyword argument %s not one of (:predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller)" delete-dups append plist-get t functionp 1 "o" ("default") ("o" identity "default") (original-source) ((original-source)) active-minibuffer-window window-minibuffer-p assoc vector cl-struct-ivy-state selected-frame selected-window ivy--reset-state make-byte-code 0 "\304\305\306\"\210\307\310!\311�!\203��\211 \210\210\300	\312H\n>\204\"�\313\314\315	D\"\210	\316H\240\203-�\300\242 \210�\317=?\2056�\320 \207" vconcat ...] 48 ("/root/.emacs.d/elpa-25.3/ivy-20180513.1037/ivy.elc" . 75464)] ("Find file: " read-file-name-internal :matcher counsel--find-file-matcher :initial-input nil :action counsel-find-file-action :preselect nil :require-match confirm-after-completion :history file-name-history :keymap (keymap (27 keymap (25 . counsel-yank-directory)) (C-backspace . counsel-up-directory) (67108991 . counsel-up-directory)) :caller counsel-find-file))
  ivy-read("Find file: " read-file-name-internal :matcher counsel--find-file-matcher :initial-input nil :action counsel-find-file-action :preselect nil :require-match confirm-after-completion :history file-name-history :keymap (keymap (27 keymap (25 . counsel-yank-directory)) (C-backspace . counsel-up-directory) (67108991 . counsel-up-directory)) :caller counsel-find-file)
  counsel-find-file()
  funcall-interactively(counsel-find-file)
  call-interactively(counsel-find-file nil nil)
  command-execute(counsel-find-file)


@lvii
Copy link
Author

lvii commented May 15, 2018

There was M-x profiler-report output when C-x C-f (counsel-find-file) hang :

Function                                                  CPU samples    %
- command-execute                                               21743  92%
 - call-interactively                                           21743  92%
  - funcall-interactively                                       21743  92%
   - counsel-find-file                                          21556  91%
    - ivy-read                                                  21556  91%
     - apply                                                    21556  91%
      - ivy-historian--nadvice/ivy-read                         21556  91%
       - apply                                                  21556  91%
        - #<compiled 0x1b571d9>                                 21556  91%
         - ivy-call                                             21405  90%
          - counsel-find-file-action                            21405  90%
           - find-file                                          21405  90%
            - find-file-noselect                                21405  90%
             - find-file-noselect-1                             21404  90%
              - after-find-file                                 21404  90%
               - normal-mode                                    21404  90%
                - set-auto-mode                                 21402  90%
                 - set-auto-mode-0                              21402  90%
                  - typescript-mode                             21390  90%
                   - run-mode-hooks                             21081  89%
                    - apply                                     21081  89%
                     - run-hooks                                21081  89%
                      - add-node-modules-path                   20702  87%
                       - expand-file-name                        4824  20%
                        - tramp-completion-file-name-handler     4565  19%
                         - tramp-completion-run-real-handler     4023  17%
                            apply                                3961  16%
                       + file-name-directory                     1707   7%
                       + directory-file-name                     1685   7%
                      + paredit-everywhere-mode                    29   0%
                      + origami-mode                               24   0%
                      + symbol-overlay-mode                         2   0%
                      + rainbow-delimiters-mode                     2   0%
                   + byte-code                                    305   1%
                + fundamental-mode                                  1   0%
             + file-truename                                        1   0%
         + read-from-minibuffer                                   150   0%
         + ivy--reset-state                                         1   0%
   + counsel-M-x                                                  187   0%
+ ...                                                            1863   7%
+ redisplay_internal (C function)                                  24   0%
  global-whitespace-cleanup-mode-check-buffers                      1   0%
+ timer-event-handler                                               1   0%

@basil-conto
Copy link

Looks like the issue lies with the interaction of the add-node-modules-path package with TRAMP when running in Docker. I don't use @purcell's configuration, but I wonder whether the issue lies with of the aforementioned actors, rather than this config?

@lvii
Copy link
Author

lvii commented May 15, 2018

I set global node_modules dir in docker mounted path and export the PATH env var :

# mount|grep home
/dev/sda2 on /home/py type xfs (rw,noatime,nodiratime,attr2,nobarrier,inode64,noquota)

# npm config set prefix '/home/py/code/npm-global'

# export PATH=/home/py/code/npm-global/bin:$PATH

# ll /home/py/code/npm-global/bin/ng
lrwxrwxrwx 1 root root 39 2018-05-11 12:16 /home/py/code/npm-global/bin/ng 
                                       -> '../lib/node_modules/@angular/cli/bin/ng'

@lvii lvii changed the title counsel-find-file open typescript files hang need 'C-g' to reopen again C-x C-f (counsel-find-file) open typescript files hang need 'C-g' to reopen again May 15, 2018
@purcell
Copy link
Owner

purcell commented May 16, 2018

Sorry, I have absolutely no way to reproduce this problem, so I'm going to close this issue, but if you figure out the problem, feel free to post the solution here.

@purcell purcell closed this as completed May 16, 2018
@lvii
Copy link
Author

lvii commented May 17, 2018

@purcell

my docker container mounted code base dir into container :

docker run --rm -it --net=host -v /home/py:/home/py --name fedora fedora

.ts code in mounted dir, when I open .ts files emacs would hang.

I have comment add-node-modules-path config for .ts files, it solved this problem

# git diff
diff --git a/lisp/init-javascript.el b/lisp/init-javascript.el
index f4871aa..e52bbe0 100644
--- a/lisp/init-javascript.el
+++ b/lisp/init-javascript.el
@@ -103,8 +103,8 @@
 
 ^L
 (when (maybe-require-package 'add-node-modules-path)
-  (after-load 'typescript-mode
-    (add-hook 'typescript-mode-hook 'add-node-modules-path))
+  ;; (after-load 'typescript-mode
+  ;;   (add-hook 'typescript-mode-hook 'add-node-modules-path))
   (after-load 'js2-mode
     (add-hook 'js2-mode-hook 'add-node-modules-path)))

@dcorking
Copy link
Contributor

Nicely done.

  1. does your codebase have a local node_modules/.bin ? I think the add-node-modules-path package depends on it. If not, then you probably don't need add-node-modules-path. If you ever use yarn or npm to add any local package with an executable, such as eslint, gulp or jest then the package might work again - and should help typescript-mode find the right version of your linter.
  2. could emacs be searching a tramp directory instead of only the container's mounted file systems?

@lvii
Copy link
Author

lvii commented May 17, 2018

@dcorking

node_modules/.bin was on the top of angular project <project>/node_modules/.bin/:

# ll /home/py/code/django/zerone/angular/zerone/node_modules/.bin/|head
total 0
lrwxrwxrwx 1 root root 18 2018-05-16 16:42 acorn -> ../acorn/bin/acorn*
lrwxrwxrwx 1 root root 26 2018-05-16 16:42 ansi-html -> ../ansi-html/bin/ansi-html*
lrwxrwxrwx 1 root root 19 2018-05-16 16:42 atob -> ../atob/bin/atob.js*
lrwxrwxrwx 1 root root 32 2018-05-16 16:42 autoprefixer -> ../autoprefixer/bin/autoprefixer*
lrwxrwxrwx 1 root root 25 2018-05-16 16:42 babylon -> ../babylon/bin/babylon.js*
lrwxrwxrwx 1 root root 34 2018-05-16 16:42 blocking-proxy -> ../blocking-proxy/built/lib/bin.js*
lrwxrwxrwx 1 root root 22 2018-05-16 16:42 browserslist -> ../browserslist/cli.js*
lrwxrwxrwx 1 root root 61 2018-05-16 16:42 build-optimizer -> ../@angular-devkit/build-optimizer/src/build-optimizer/cli.js*
lrwxrwxrwx 1 root root 20 2018-05-16 16:42 cssesc -> ../cssesc/bin/cssesc*

the source code dir was under <project>/src/app/ ( second level dir of angular project ).

there was NO more node_modules/.bin under <project>/src/ source dir:

# tree -F -d -L 2 /home/py/code/django/zerone/angular/zerone/src/
/home/py/code/django/zerone/angular/zerone/src/
├── app
│   ├── default
│   ├── layout
│   ├── login
│   └── search
├── assets
└── environments

8 directories

I think if add-node-modules-path could be configured like exec-path would be better.

@dcorking
Copy link
Contributor

dcorking commented May 17, 2018

That might be a useful patch to offer to that project's maintainer. In the meantime, configure exec-path in your init-local.el as that is the purpose of add-node-modules-path.

The package works for me in an Angular project on a local filesystem mount. It should work for you as it does little more than rely on Emacs built-in files library

@basil-conto
Copy link

basil-conto commented May 17, 2018

It should work for you as it does little more than rely on Emacs built-in files library

FWIW, that's not saying much - it is very easy for built-in filesystem-bound functions to fail/hang and be very hard to debug when dealing with file handlers, e.g. when TRAMP is involved. That is why you will often see people guard, say, file-directory-p calls with file-remote-p.

Although it would, of course, be nice to address any issues with add-node-modules-path, if @lvii can get by with adjusting exec-path directly, rather than relying add-node-modules-path, and if that avoids the problem, then that's also a solution.

@lvii Have you tried inspecting the output produced when add-node-modules-path-debug is set to a non-nil value?

@dcorking
Copy link
Contributor

@basil-conto thanks for the caveats about Emacs file primitives. I don't understand why tramp completion is invoked on OP's container. Also, if directory traversal depends on remote file access, as it seems to, I would expect all kinds of things to break on OP's container, such as helm, magit and projectile. Probably I have spent enough time on this, as the fix is simple, even though the cause is beyond my current level of Emacs knowledge.

@dcorking
Copy link
Contributor

@lvii the package was completely re-written a few days ago to stop at your home directory. A package upgrade to version 20180501.49 will probably mitigate your issue.

@basil-conto
Copy link

I don't understand why tramp completion is invoked on OP's container.

I'm not familiar with these TRAMP subtleties either, though I do know that the variables non-essential and tramp-completion-mode (obsolete since Emacs 26.1) are relevant to file name completion.

Also, if directory traversal depends on remote file access, as it seems to, I would expect all kinds of things to break on OP's container, such as helm, magit and projectile.

Not necessarily, as add-node-modules-path is performing custom and potentially TRAMP-incompatible filesystem traversal, whereas other packages let file handlers and external executables do the work for them (this is just my guess).

@lvii The current TRAMP maintainer is very active and helpful, so they may be able to give you some useful pointers if you ask nicely. See (tramp) Bug Reports for info on contacting them.

@lvii
Copy link
Author

lvii commented May 17, 2018

@dcorking

After I updated installed packages, this problem was still unsolved in docker container mounted dir:

add-node-module... 20180501.49   installed       Add node_modules to your exec-path
counsel            20180515.1057 installed       Various completion functions using Ivy

I have cloned source code at container's local /root dir NOT in mounted path.

There would be NO problem.

When opening local files in container, there was NOT calling tramp

Function                                                  CPU samples    %
- command-execute                                                1260  70%
 - call-interactively                                            1260  70%
  - funcall-interactively                                        1260  70%
   - counsel-find-file                                            814  45%
    - ivy-read                                                    814  45%
     - apply                                                      814  45%
      - ivy-historian--nadvice/ivy-read                           814  45%
       - apply                                                    814  45%
        - #<compiled 0x18d4b77>                                   814  45%
         - ivy-call                                               486  27%
          - counsel-find-file-action                              486  27%
           - find-file                                            486  27%
            + find-file-noselect                                  484  27%
            - switch-to-buffer                                      2   0%
             + set-window-buffer                                    2   0%
         + read-from-minibuffer                                   325  18%
         - ivy--reset-state                                         3   0%
          + ivy-thing-at-point                                      2   0%
          + ivy--sorted-files                                       1   0%
   + counsel-M-x                                                  446  24%
+ ...                                                             480  26%
+ redisplay_internal (C function)                                  45   2%
+ timer-event-handler                                               3   0%
+ flycheck-handle-signal                                            3   0%

@basil-conto

I have enable add-node-modules-path-debug in init-local.el.

Here was the new debug output of the hang problem: http://ix.io/1aDU

@basil-conto
Copy link

@lvii

I have enable add-node-modules-path-debug in init-local.el.
Here was the new debug output of the hang problem: http://ix.io/1aDU

Enabling add-node-modules-path-debug sends add-node-modules-path-specific output to the *Messages* buffer; it doesn't affect the debug-on-quit backtrace.

@lvii
Copy link
Author

lvii commented May 18, 2018

@basil-conto

It seemed that there was no any debug output with add-node-modules-path in *Messages* buffer.

Loading /root/.emacs.d/custom.el (source)...done
Loading /root/.emacs.d/.session...done
No desktop file.
Desktop restored in 0.38ms
Loading /root/.emacs.d/recentf...done
Cleaning up the recentf list...done (0 removed)
init completed in 1897.13ms
For information about GNU Emacs and the GNU system, type C-h C-a.
Quit [6 times]                                                   <-- hang
Type "q" in help window to restore its previous buffer.
Quit [5 times]

C-x C-g is undefined
Quit [4 times]
Debug on Quit enabled globally                                   <-- M-x toggle-debug-on-quit
Entering debugger...                                             <-- hang

@basil-conto
Copy link

@lvii I suggest you bring this issue up with the add-node-modules-path and TRAMP maintainers, and/or try to Edebug it yourself.

@dcorking
Copy link
Contributor

Switch off TRAMP and restart Emacs to see if it helps narrow down your issue. https://stackoverflow.com/a/1708205/1899424 If you find the cause, come back here and let us know if you recommend changes in purcell/emacs.d

@purcell
Copy link
Owner

purcell commented May 20, 2018

@dcorking Thanks for helping out by leaving comments and providing support on so many issues - it's much appreciated.

@codesuki
Copy link

@basil-conto do you have any link for me that describes TRAMP-compatible path traversal?
I personally never use TRAMP so that I didn't have this issue, but if it helps someone I will make changes / merge a PR.

@basil-conto
Copy link

basil-conto commented May 23, 2018

@codesuki

do you have any link for me that describes TRAMP-compatible path traversal?

No; when I said that, I meant using operations that don't assume a local filesystem and work in the presence of file handlers, that's all (all of my comments above are speculative). The only documentation I'm aware of is (elisp) Files and the TRAMP manual itself. If you have any particular questions feel free to send mail to tramp-devel@gnu.org; the library's maintainer is pretty active and helpful.

@codesuki
Copy link

I see, thanks! The problem for @lvii is fixed now. The problem was a recent change that, instead of just searching in the current project folder, walked up until the users home directory to find node_modules. That results in an infinite loop if the file is not below your home directory.

@lvii
Copy link
Author

lvii commented May 24, 2018

@codesuki

If add-node-modules-path searching node_modules path from PATH env var or ~/.npmrc global path config, this would be a better idea. Hope you could consider it.

@codesuki
Copy link

Thanks for the suggestion! I am in release mode at work now so all hands full. Maybe you can send a PR!

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

5 participants