dajva / rg.el

Emacs search tool based on ripgrep
https://rgel.readthedocs.io
GNU General Public License v3.0
474 stars 39 forks source link

Wrong type argument: stringp, nil #68

Closed ForLoveOfCats closed 4 years ago

ForLoveOfCats commented 4 years ago

When running the simple (rg-run "foo" "*.baz" default-directory) the error Wrong type argument: stringp, nil is emitted. This doesn't make much sense as the tests are littered with calls such as this one (rg-run "foo" "*.baz" (concat default-directory "dirlocals")). My local rg.el version is up to date with Melpa (not Melpa stable).


Debugger trace:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("[ \011\n\015]+\\'" nil)
  s-trim-right(nil)
  s-trim(nil)
  #f(compiled-function (type-alias) #<bytecode 0x16f6de1>)("")
  mapcar(#f(compiled-function (type-alias) #<bytecode 0x16f6de1>) ("" "agda: *.agda, *.lagda" "aidl: *.aidl" "amake: *.bp, *.mk" "asciidoc: *.adoc, *.asc, *.asciidoc" "asm: *.S, *.asm, *.s" "asp: *.ascx, *.ascx.cs, *.ascx.vb, *.aspx, *.aspx.cs, *.aspx.cs" "ats: *.ats, *.dats, *.hats, *.sats" "avro: *.avdl, *.avpr, *.avsc" "awk: *.awk" "bazel: *.bzl, BUILD, BUILD.bazel, WORKSPACE" "bitbake: *.bb, *.bbappend, *.bbclass, *.conf, *.inc" "brotli: *.br" "buildstream: *.bst" "bzip2: *.bz2, *.tbz2" "c: *.[chH], *.[chH].in, *.cats" "cabal: *.cabal" "cbor: *.cbor" "ceylon: *.ceylon" "clojure: *.clj, *.cljc, *.cljs, *.cljx" "cmake: *.cmake, CMakeLists.txt" "coffeescript: *.coffee" "config: *.cfg, *.conf, *.config, *.ini" "cpp: *.[ChH], *.[ChH].in, *.[ch]pp, *.[ch]pp.in, *.[ch]xx, *.[ch]xx.in, *.cc, *.cc.in, *.hh, *.hh.in, *.inl" "creole: *.creole" "crystal: *.cr, Projectfile" "cs: *.cs" "csharp: *.cs" "cshtml: *.cshtml" "css: *.css, *.scss" "csv: *.csv" "cython: *.pxd, *.pxi, *.pyx" "d: *.d" "dart: *.dart" "dhall: *.dhall" "docker: *Dockerfile*" "edn: *.edn" "elisp: *.el" "elixir: *.eex, *.ex, *.exs" "elm: *.elm" "erlang: *.erl, *.hrl" "fidl: *.fidl" "fish: *.fish" "fortran: *.F, *.F77, *.F90, *.F95, *.f, *.f77, *.f90, *.f95, *.pfo" "fsharp: *.fs, *.fsi, *.fsx" "gap: *.g, *.gap, *.gd, *.gi, *.tst" "gn: *.gn, *.gni" "go: *.go" "groovy: *.gradle, *.groovy" "gzip: *.gz, *.tgz" ...))
  rg-list-builtin-type-aliases()
  rg-get-type-aliases()
  rg-is-custom-file-pattern("*.baz")
  rg-build-command("foo" "*.baz" nil ("-i"))
  rg-run("foo" "*.baz" "/home/forloveofcats/Dotfiles/")
  nav/rg-project()
  (lambda nil (interactive) (nav/disable) (nav/rg-project))()
  funcall-interactively((lambda nil (interactive) (nav/disable) (nav/rg-project)))
  call-interactively((lambda nil (interactive) (nav/disable) (nav/rg-project)) nil nil)
  command-execute((lambda nil (interactive) (nav/disable) (nav/rg-project)))
dajva commented 4 years ago

What version of ripgrep is this and what OS is this? The empty string at the begining of the type list should be the problem but I don't know why you get that.

ForLoveOfCats commented 4 years ago

image

dajva commented 4 years ago

Ok, I have essentially the same environgment (linux rg version) so no clue there. There is an empty string at the end of the type list though coming from splitting the output from rg --type-list on newline. That one is filtered out to avoid these kind of problems. I guess the simplest solution to this is just to handle empty strings gracefully when processing the list. Should make it more resiliant to any strangeness in this area.

dajva commented 4 years ago

Pushed a fix now. Let's see if this works.

ForLoveOfCats commented 4 years ago

I can confirm that the issue has been resolved on my system! Thanks for your time and effort on this library!