Doom-emacs: error code 2 on project searches with ripgrep

Created on 5 May 2020  Â·  5Comments  Â·  Source: hlissner/doom-emacs

What did you expect to happen?

Expected a partial result from +default/search-project using ripgrep.

What actually happened?

If the user has no permission to a folder inside the project, the command returns error code 2 and no results are returned.

Steps to reproduce:

  1. Create a folder inside a project
  2. Remove the permissions for your user from the folder
  3. Try to search using +default/search-project

System information:


((emacs
(version . "26.3")
(features . "XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS LIBSYSTEMD LCMS2")
(build . "Sep 16, 2019")
(buildopts "--build=x86_64-linux-gnu --prefix=/usr '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib --program-suffix=26 --with-modules --with-file-notification=inotify --with-mailutils --with-x=yes --with-x-toolkit=gtk3 --with-xwidgets --with-lcms2 'CFLAGS=-g -O2 -fdebug-prefix-map=/build/emacs26-TP6iDo/emacs26-26.3~1.git96dd019=. -fstack-protector-strong -Wformat -Werror=format-security -no-pie' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -no-pie'")
(windowsys . batch)
(daemonp . server-running))
(doom
(version . "2.0.9")
(build . "HEAD -> develop 35591cfc4 2020-05-04 16:53:26 -0400")
(dir . "~/.doom.d/"))
(system
(type . gnu/linux)
(config . "x86_64-pc-linux-gnu")
(shell . "/usr/bin/zsh")
(uname . "Linux 4.15.0-99-generic #100-Ubuntu SMP Wed Apr 22 20:32:56 UTC 2020 x86_64")
(path "/usr/local/sbin" "/usr/local/bin" "/usr/sbin" "/usr/bin" "/sbin" "/bin" "/usr/games" "/usr/local/games" "~/.fzf/bin" "~/.local/bin" "~/.npm/bin" "~/dev/other/capi" "~/.fzf/bin" "~/.yarn/bin" "~/.emacs.d/bin" "~/.poetry/bin" "/usr/lib/x86_64-linux-gnu/emacs/26.3/x86_64-linux-gnu"))
(config
(envfile . envvar-file)
(elc-files . 0)
(modules :completion company helm (ivy +childframe +icons +fuzzy) :ui doom doom-dashboard hl-todo indent-guides modeline nav-flash ophints (popup +all +defaults) treemacs vc-gutter vi-tilde-fringe window-select workspaces :editor file-templates fold multiple-cursors rotate-text snippets :emacs (dired +icons) electric ibuffer undo vc :term term :checkers syntax spell :tools editorconfig (eval +overlay) (lookup +docsets) lsp magit pass pdf :lang data emacs-lisp json javascript latex markdown (org +dragndrop +pandoc +ipython +gnuplot +present) plantuml (python +lsp) (rust +lsp) sh yaml :app irc :config (default +bindings +smartparens))
(packages (prettier-js) (sphinx-doc) (org-caldav) (org-ref))
(unpin "n/a")
(elpa "n/a")))

:completion ivy external has-workaround

Most helpful comment

This is a known issue with how counsel-rg interprets its program's error codes -- or perhaps how ripgrep returns a fatal error code despite a partial result. A crude workaround for this would be:

;; Will only work on macos/linux
(after! counsel
  (setq counsel-rg-base-command "rg -M 240 --with-filename --no-heading --line-number --color never %s || true"))

EDIT: Fixed typo in workaround

All 5 comments

This is a known issue with how counsel-rg interprets its program's error codes -- or perhaps how ripgrep returns a fatal error code despite a partial result. A crude workaround for this would be:

;; Will only work on macos/linux
(after! counsel
  (setq counsel-rg-base-command "rg -M 240 --with-filename --no-heading --line-number --color never %s || true"))

EDIT: Fixed typo in workaround

I run into a similar issue (on macOS). I don't think there's a permission issue. If I run the following command in my project folder, it works just fine:

rg --with-filename --no-heading --line-number --color never TEXT

If I try to apply the above workaround, Emacs is giving me the following error during startup:

Loading /Users/mpilman/.emacs.frameg...done
Doom loaded 183 packages across 38 modules in 1.178s
Error in pre-command-hook (doom-first-input-hook-h): (wrong-type-argument characterp "rg")
setq: Wrong type argument: characterp, "rg"

@sfc-gh-mpilman Try this instead:

(after! counsel
  (setq counsel-rg-base-command "rg -M 240 --with-filename --no-heading --line-number --color never %s || true"))

@hlissner this works!! Perfect, thank you so much :)

I have same problem under Windows 10.

Some times when I input the first char of query text, +default/search-project show correct search result, but if I continue to input remain chars, the problem occur.

Then I found if I disable +prescient for module ivy, the search works well.

https://github.com/raxod502/prescient.el/issues/43

Was this page helpful?
0 / 5 - 0 ratings