Creating pipe: too many open files after `SPC *`

What happened?

After pressing SPC + * I got an (file-error "Creating pipe" "too many open files") error. However, I don’t see this error every time, seems like my Emacs instance goes t a specific state after some hours where this error happens with any command related to files.

What did you expect to happen?

To see all the matches of the symbol at point without any errors.

Steps to reproduce

  1. Place your cursor over a symbol
  2. Press SPC + *

System information


Loading data dump...

M-x toggle-debug-on-error

  Debugger entered--Lisp error: (file-error "Creating pipe" "Too many open files")
  #<subr make-process>(:file-handler t :connection-type pipe :name "rg" :stderr #<buffer  *consult-async-stderr*-453411> :noquery t :command ("rg" "--null" "--line-buffered" "--color=never" "--max-columns=1000" "--path-separator" "/" "--smart-case" "--no-heading" "--line-number" "--hidden" "-g" "!.git" "-g" "!.svn" "-g" "!.hg" "." "-P" "-e" "Commands") :filter #f(compiled-function (_ out) #<bytecode 0xd178e5dcc7e935d>) :sentinel #f(compiled-function (_ event) #<bytecode -0xef658f973134250>))
  apply(#<subr make-process> (:file-handler t :connection-type pipe :name "rg" :stderr #<buffer  *consult-async-stderr*-453411> :noquery t :command ("rg" "--null" "--line-buffered" "--color=never" "--max-columns=1000" "--path-separator" "/" "--smart-case" "--no-heading" "--line-number" "--hidden" "-g" "!.git" "-g" "!.svn" "-g" "!.hg" "." "-P" "-e" "Commands") :filter #f(compiled-function (_ out) #<bytecode 0xd178e5dcc7e935d>) :sentinel #f(compiled-function (_ event) #<bytecode -0xef658f973134250>)))
  (if (or (not file-handler) (not with-editor--envvar)) (apply fn keys) (if (file-remote-p default-directory) (progn (if (equal (car command) "env") nil (setq command (cons "env" command))) (let* ((x (concat with-editor--envvar "=" with-editor-sleeping-editor)) (v command)) (setcdr v (cons x (cdr v)))))) (let* ((filter (if filter #'(lambda (process output) (funcall filter process output) (with-editor-process-filter process output t)) #'with-editor-process-filter)) (process (funcall fn :name name :buffer buffer :command command :coding coding :noquery noquery :stop stop :connection-type connection-type :filter filter :sentinel sentinel :stderr stderr :file-handler file-handler))) (process-put process 'default-dir default-directory) process))
  (let* ((name (car (cdr (plist-member keys ':name)))) (buffer (car (cdr (plist-member keys ':buffer)))) (command (car (cdr (plist-member keys ':command)))) (coding (car (cdr (plist-member keys ':coding)))) (noquery (car (cdr (plist-member keys ':noquery)))) (stop (car (cdr (plist-member keys ':stop)))) (connection-type (car (cdr (plist-member keys ':connection-type)))) (filter (car (cdr (plist-member keys ':filter)))) (sentinel (car (cdr (plist-member keys ':sentinel)))) (stderr (car (cdr (plist-member keys ':stderr)))) (file-handler (car (cdr (plist-member keys ':file-handler))))) (if (or (not file-handler) (not with-editor--envvar)) (apply fn keys) (if (file-remote-p default-directory) (progn (if (equal (car command) "env") nil (setq command (cons "env" command))) (let* ((x (concat with-editor--envvar "=" with-editor-sleeping-editor)) (v command)) (setcdr v (cons x (cdr v)))))) (let* ((filter (if filter #'(lambda ... ... ...) #'with-editor-process-filter)) (process (funcall fn :name name :buffer buffer :command command :coding coding :noquery noquery :stop stop :connection-type connection-type :filter filter :sentinel sentinel :stderr stderr :file-handler file-handler))) (process-put process 'default-dir default-directory) process)))
  make-process--with-editor-process-filter(#<subr make-process> :file-handler t :connection-type pipe :name "rg" :stderr #<buffer  *consult-async-stderr*-453411> :noquery t :command ("rg" "--null" "--line-buffered" "--color=never" "--max-columns=1000" "--path-separator" "/" "--smart-case" "--no-heading" "--line-number" "--hidden" "-g" "!.git" "-g" "!.svn" "-g" "!.hg" "." "-P" "-e" "Commands") :filter #f(compiled-function (_ out) #<bytecode 0xd178e5dcc7e935d>) :sentinel #f(compiled-function (_ event) #<bytecode -0xef658f973134250>))
  apply(make-process--with-editor-process-filter #<subr make-process> (:file-handler t :connection-type pipe :name "rg" :stderr #<buffer  *consult-async-stderr*-453411> :noquery t :command ("rg" "--null" "--line-buffered" "--color=never" "--max-columns=1000" "--path-separator" "/" "--smart-case" "--no-heading" "--line-number" "--hidden" "-g" "!.git" "-g" "!.svn" "-g" "!.hg" "." "-P" "-e" "Commands") :filter #f(compiled-function (_ out) #<bytecode 0xd178e5dcc7e935d>) :sentinel #f(compiled-function (_ event) #<bytecode -0xef658f973134250>)))
  make-process(:file-handler t :connection-type pipe :name "rg" :stderr #<buffer  *consult-async-stderr*-453411> :noquery t :command ("rg" "--null" "--line-buffered" "--color=never" "--max-columns=1000" "--path-separator" "/" "--smart-case" "--no-heading" "--line-number" "--hidden" "-g" "!.git" "-g" "!.svn" "-g" "!.hg" "." "-P" "-e" "Commands") :filter #f(compiled-function (_ out) #<bytecode 0xd178e5dcc7e935d>) :sentinel #f(compiled-function (_ event) #<bytecode -0xef658f973134250>))
  apply(make-process (:file-handler t :connection-type pipe :name "rg" :stderr #<buffer  *consult-async-stderr*-453411> :noquery t :command ("rg" "--null" "--line-buffered" "--color=never" "--max-columns=1000" "--path-separator" "/" "--smart-case" "--no-heading" "--line-number" "--hidden" "-g" "!.git" "-g" "!.svn" "-g" "!.hg" "." "-P" "-e" "Commands") :filter #f(compiled-function (_ out) #<bytecode 0xd178e5dcc7e935d>) :sentinel #f(compiled-function (_ event) #<bytecode -0xef658f973134250>)))
  #f(compiled-function (action) #<bytecode -0x134c99e9c38979e4>)("Commands")
  #f(compiled-function () #<bytecode -0xe9a647ee8afa97a>)()
  apply(#f(compiled-function () #<bytecode -0xe9a647ee8afa97a>) nil)
  timer-event-handler([t 25197 42131 680279 nil #f(compiled-function () #<bytecode -0xe9a647ee8afa97a>) nil nil 0 nil])
  read-from-minibuffer("Search (Project evil): " "#Commands" (keymap (insert-state keymap (11 . previous-line) (10 . next-line) "Auxiliary keymap for Insert state") (33554443 . scroll-down-command) (33554442 . scroll-up-command) (11 . previous-line) (26 closure (t) (&rest _) (interactive) (condition-case nil (progn (call-interactively #'undo)) (error nil))) (23 . doom/delete-backward-word) (22 . yank) (21 . evil-delete-back-to-indentation) (18 . evil-paste-from-register) (1 . move-beginning-of-line) (escape . abort-recursive-edit) (19 . consult-history) (10 . next-line) (13 . minibuffer-complete-and-exit) keymap (insert-state keymap (11 . previous-line) (10 . next-line) "Auxiliary keymap for Insert state") (33554443 . scroll-down-command) (33554442 . scroll-up-command) (11 . previous-line) (10 . next-line) (26 closure (t) (&rest _) (interactive) (condition-case nil (progn (call-interactively #'undo)) (error nil))) (23 . doom/delete-backward-word) (22 . yank) (21 . evil-delete-back-to-indentation) (18 . evil-paste-from-register) (1 . move-beginning-of-line) (escape . abort-recursive-edit) (19 . consult-history) (menu-bar keymap (minibuf "Minibuf" keymap (tab menu-item "Complete" minibuffer-complete :help "Complete as far as possible") (space menu-item "Complete Word" minibuffer-complete-word :help "Complete at most one word") (63 menu-item "List Completions" minibuffer-completion-help :help "Display all possible completions") "Minibuf")) (27 keymap (103 keymap (27 keymap (99 . switch-to-completions))) (118 . switch-to-completions)) (prior . switch-to-completions) (63 . minibuffer-completion-help) (32 . minibuffer-complete-word) (9 . minibuffer-complete) keymap (insert-state keymap "Auxiliary keymap for Insert state" (11 . previous-line) (10 . next-line)) (33554443 . scroll-down-command) (33554442 . scroll-up-command) (11 . previous-line) (26 closure (t) (&rest _) (interactive) (condition-case nil (progn (call-interactively #'undo)) (error nil))) (23 . doom/delete-backward-word) (22 . yank) (21 . evil-delete-back-to-indentation) (18 . evil-paste-from-register) (1 . move-beginning-of-line) (escape . abort-recursive-edit) (19 . consult-history) (3 keymap (5 . +vertico/embark-export-write) (12 . embark-collect) (67108923 . embark-export)) (67108923 . embark-act) ...) nil consult--grep-history nil nil)
  #f(compiled-function (prompt collection &optional predicate require-match initial-input hist def inherit-input-method) "Default method for reading from the minibuffer with completion.\nSee `completing-read' for the meaning of the arguments." #<bytecode 0x129095f522a3f1ab>)("Search (Project evil): " #f(compiled-function (str pred action) #<bytecode 0x66c9ec77c53958c>) nil t "#Commands" consult--grep-history nil nil)
  apply((#f(compiled-function (prompt collection &optional predicate require-match initial-input hist def inherit-input-method) "Default method for reading from the minibuffer with completion.\nSee `completing-read' for the meaning of the arguments." #<bytecode 0x129095f522a3f1ab>) "Search (Project evil): " #f(compiled-function (str pred action) #<bytecode 0x66c9ec77c53958c>) nil t "#Commands" consult--grep-history nil nil))
  vertico--advice(#f(compiled-function (prompt collection &optional predicate require-match initial-input hist def inherit-input-method) "Default method for reading from the minibuffer with completion.\nSee `completing-read' for the meaning of the arguments." #<bytecode 0x129095f522a3f1ab>) "Search (Project evil): " #f(compiled-function (str pred action) #<bytecode 0x66c9ec77c53958c>) nil t "#Commands" consult--grep-history nil nil)
  apply(vertico--advice #f(compiled-function (prompt collection &optional predicate require-match initial-input hist def inherit-input-method) "Default method for reading from the minibuffer with completion.\nSee `completing-read' for the meaning of the arguments." #<bytecode 0x129095f522a3f1ab>) ("Search (Project evil): " #f(compiled-function (str pred action) #<bytecode 0x66c9ec77c53958c>) nil t "#Commands" consult--grep-history nil nil))
  completing-read-default("Search (Project evil): " #f(compiled-function (str pred action) #<bytecode 0x66c9ec77c53958c>) nil t "#Commands" consult--grep-history nil nil)
  completing-read("Search (Project evil): " #f(compiled-function (str pred action) #<bytecode 0x66c9ec77c53958c>) nil t "#Commands" consult--grep-history nil nil)
  #f(compiled-function () #<bytecode -0xc285f0ff39361d8>)()
  consult--with-preview-1([67108896] #f(compiled-function (action cand) #<bytecode 0x173275e864e54dc6>) #f(compiled-function (input cand) #<bytecode 0x18c525436d6a6502>) #f(compiled-function (&rest args2) #<bytecode -0xae2675aa39b253f>) #f(compiled-function () #<bytecode -0xc285f0ff39361d8>))
  consult--read-1(#f(compiled-function (action) #<bytecode 0x1817d1a347fd41bc>) :preview-key [67108896] :prompt "Search (Project evil): " :lookup consult--lookup-member :state #f(compiled-function (action cand) #<bytecode 0x173275e864e54dc6>) :initial "#Commands" :add-history #("#Commands" 1 9 (ws-butler-chg chg wrap-prefix #("    " 0 4 (face org-indent)) line-prefix #("    " 0 4 (face org-indent)) fontified t face org-table)) :require-match t :category consult-grep :group consult--grep-group :history (:input consult--grep-history) :sort nil :prompt "Select: " :preview-key [134217774] :sort t :lookup #f(compiled-function (input cands x) #<bytecode 0x4aac387ed301287>))
  apply(consult--read-1 #f(compiled-function (action) #<bytecode 0x1817d1a347fd41bc>) (:preview-key [67108896] :prompt "Search (Project evil): " :lookup consult--lookup-member :state #f(compiled-function (action cand) #<bytecode 0x173275e864e54dc6>) :initial "#Commands" :add-history #("#Commands" 1 9 (ws-butler-chg chg wrap-prefix #("    " 0 4 (face org-indent)) line-prefix #("    " 0 4 (face org-indent)) fontified t face org-table)) :require-match t :category consult-grep :group consult--grep-group :history (:input consult--grep-history) :sort nil :prompt "Select: " :preview-key [134217774] :sort t :lookup #f(compiled-function (input cands x) #<bytecode 0x4aac387ed301287>)))
  consult--read(#f(compiled-function (action) #<bytecode 0x1817d1a347fd41bc>) :prompt "Search (Project evil): " :lookup consult--lookup-member :state #f(compiled-function (action cand) #<bytecode 0x173275e864e54dc6>) :initial "#Commands" :add-history #("#Commands" 1 9 (ws-butler-chg chg wrap-prefix #("    " 0 4 (face org-indent)) line-prefix #("    " 0 4 (face org-indent)) fontified t face org-table)) :require-match t :category consult-grep :group consult--grep-group :history (:input consult--grep-history) :sort nil)
  consult--grep("Search" consult--ripgrep-builder "/Users/wferreir/code/evil/" "Commands")
  (let* ((project-root (or (doom-project-root) default-directory)) (directory (or in project-root)) (consult-ripgrep-args (concat "rg " (if all-files "-uu ") (if recursive nil "--maxdepth 1 ") "--null --line-buffered --color=never --max-columns..." "--path-separator /   --smart-case --no-heading --l..." "--hidden -g !.git -g !.svn -g !.hg " (mapconcat #'shell-quote-argument args " ") " .")) (prompt (if (stringp prompt) (string-trim prompt) "Search")) (query (or query (if (doom-region-active-p) (progn (regexp-quote (doom-thing-at-point-or-region)))))) (consult-async-split-style consult-async-split-style) (consult-async-split-styles-alist consult-async-split-styles-alist)) (if query (progn (let* ((--cl-rest-- (consult--async-split-style)) (type (car (cdr ...))) (separator (car (cdr ...))) (initial (car (cdr ...)))) (progn (let ((--cl-keys-- --cl-rest--)) (while --cl-keys-- (cond ... ... ...))) (cond ((eq type ...) (let nil ...)) ((eq type ...) (let nil ...))))))) (consult--grep prompt #'consult--ripgrep-builder directory query))
  (progn (if (executable-find "rg") nil (user-error "Couldn't find ripgrep in your PATH")) (require 'consult) (setq deactivate-mark t) (let* ((project-root (or (doom-project-root) default-directory)) (directory (or in project-root)) (consult-ripgrep-args (concat "rg " (if all-files "-uu ") (if recursive nil "--maxdepth 1 ") "--null --line-buffered --color=never --max-columns..." "--path-separator /   --smart-case --no-heading --l..." "--hidden -g !.git -g !.svn -g !.hg " (mapconcat #'shell-quote-argument args " ") " .")) (prompt (if (stringp prompt) (string-trim prompt) "Search")) (query (or query (if (doom-region-active-p) (progn (regexp-quote ...))))) (consult-async-split-style consult-async-split-style) (consult-async-split-styles-alist consult-async-split-styles-alist)) (if query (progn (let* ((--cl-rest-- (consult--async-split-style)) (type (car ...)) (separator (car ...)) (initial (car ...))) (progn (let (...) (while --cl-keys-- ...)) (cond (... ...) (... ...)))))) (consult--grep prompt #'consult--ripgrep-builder directory query)))
  (progn (let ((--cl-keys-- --cl-rest--)) (while --cl-keys-- (cond ((memq (car --cl-keys--) '(:query :in :all-files :recursive :prompt :args :allow-other-keys)) (setq --cl-keys-- (cdr (cdr --cl-keys--)))) ((car (cdr (memq ... --cl-rest--))) (setq --cl-keys-- nil)) (t (error "Keyword argument %s not one of (:query :in :all-fi..." (car --cl-keys--)))))) (progn (if (executable-find "rg") nil (user-error "Couldn't find ripgrep in your PATH")) (require 'consult) (setq deactivate-mark t) (let* ((project-root (or (doom-project-root) default-directory)) (directory (or in project-root)) (consult-ripgrep-args (concat "rg " (if all-files "-uu ") (if recursive nil "--maxdepth 1 ") "--null --line-buffered --color=never --max-columns..." "--path-separator /   --smart-case --no-heading --l..." "--hidden -g !.git -g !.svn -g !.hg " (mapconcat #'shell-quote-argument args " ") " .")) (prompt (if (stringp prompt) (string-trim prompt) "Search")) (query (or query (if (doom-region-active-p) (progn ...)))) (consult-async-split-style consult-async-split-style) (consult-async-split-styles-alist consult-async-split-styles-alist)) (if query (progn (let* ((--cl-rest-- ...) (type ...) (separator ...) (initial ...)) (progn (let ... ...) (cond ... ...))))) (consult--grep prompt #'consult--ripgrep-builder directory query))))
  (let* ((query (car (cdr (plist-member --cl-rest-- ':query)))) (in (car (cdr (plist-member --cl-rest-- ':in)))) (all-files (car (cdr (plist-member --cl-rest-- ':all-files)))) (recursive (car (cdr (or (plist-member --cl-rest-- ':recursive) '(nil t))))) (prompt (car (cdr (plist-member --cl-rest-- ':prompt)))) (args (car (cdr (plist-member --cl-rest-- ':args))))) (progn (let ((--cl-keys-- --cl-rest--)) (while --cl-keys-- (cond ((memq (car --cl-keys--) '...) (setq --cl-keys-- (cdr ...))) ((car (cdr ...)) (setq --cl-keys-- nil)) (t (error "Keyword argument %s not one of (:query :in :all-fi..." (car --cl-keys--)))))) (progn (if (executable-find "rg") nil (user-error "Couldn't find ripgrep in your PATH")) (require 'consult) (setq deactivate-mark t) (let* ((project-root (or (doom-project-root) default-directory)) (directory (or in project-root)) (consult-ripgrep-args (concat "rg " (if all-files "-uu ") (if recursive nil "--maxdepth 1 ") "--null --line-buffered --color=never --max-columns..." "--path-separator /   --smart-case --no-heading --l..." "--hidden -g !.git -g !.svn -g !.hg " (mapconcat ... args " ") " .")) (prompt (if (stringp prompt) (string-trim prompt) "Search")) (query (or query (if ... ...))) (consult-async-split-style consult-async-split-style) (consult-async-split-styles-alist consult-async-split-styles-alist)) (if query (progn (let* (... ... ... ...) (progn ... ...)))) (consult--grep prompt #'consult--ripgrep-builder directory query)))))
  +vertico-file-search(:query "Commands" :in "/Users/wferreir/code/evil/" :all-files nil)
  +vertico/project-search(nil "Commands" "/Users/wferreir/code/evil/")
  (cond (nil (+ivy/project-search nil symbol dir)) (nil (+helm/project-search nil symbol dir)) (t (+vertico/project-search nil symbol dir)) ((rgrep (regexp-quote symbol))))
  +default/search-project-for-symbol-at-point("Commands" "/Users/wferreir/code/evil/")
  funcall-interactively(+default/search-project-for-symbol-at-point "Commands" "/Users/wferreir/code/evil/")
  call-interactively(+default/search-project-for-symbol-at-point nil nil)
  command-execute(+default/search-project-for-symbol-at-point)

To me that sounds like Emacs eats up file descriptors, opening new ones but probably not releasing old ones. You could use lsof -c emacs (if emacs is the command name) to check what it has opened when you have this issue again.

I don’t use mac, afaik there are different Emacs binaries/packages, maybe this does not happen with others? I think you can also set the file descripter limit higher, but if there is a leak it will only prolong the time until you get the same error.

1 Like

Unfortunately I don’t know what the solution to this is, but as an aside: please use the [kbd]SPC *[/kbd] to make SPC* when writing keybindings, at first I thought you meant SPC then + then *. See the style guide for more info.

1 Like

Seems that MacOs is the culprit here, I don’t remember the exact reason for this, but if you google a bit you will stumble upon reddit and stack overflow threads talking about this same exact issue, but when trying to do different things, although always trying to manipulate a certain amount of files. A common example is when trying to use magit on a large project.

Anyway, I have fixed this following this gist

The error still pop ups from time to time, but less than before.

Thanks for the link. I’ll change the limit in macOS and verify if this at least gets better.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.