Projectile: file-missing "Setting current directory" "No such file or directory"

Created on 1 Oct 2018  ·  17Comments  ·  Source: bbatsov/projectile

Expected behavior

projectile-find-file lets me browse my project files.

Actual behavior

Debugger entered--Lisp error: (file-missing "Setting current directory" "No such file or directory" "/home/manuel/7bridges/code/gaypa-docs/conf/docker/...")
  call-process("/bin/bash" nil t nil "-c" "git submodule --quiet foreach 'echo $path' | tr '\\...")
  call-process-shell-command("git submodule --quiet foreach 'echo $path' | tr '\\..." nil t)
  #f(compiled-function (command &optional output-buffer error-buffer) "Execute string COMMAND in inferior shell; display output, if any.\nWith prefix argument, insert the COMMAND's output at point.\n\nInteractively, prompt for COMMAND in the minibuffer.\n\nIf COMMAND ends in `&', execute it asynchronously.\nThe output appears in the buffer `*Async Shell Command*'.\nThat buffer is in shell mode.  You can also use\n`async-shell-command' that automatically adds `&'.\n\nOtherwise, COMMAND is executed synchronously.  The output appears in\nthe buffer `*Shell Command Output*'.  If the output is short enough to\ndisplay in the echo area (which is determined by the variables\n`resize-mini-windows' and `max-mini-window-height'), it is shown\nthere, but it is nonetheless available in buffer `*Shell Command\nOutput*' even though that buffer is not automatically displayed.\n\nTo specify a coding system for converting non-ASCII characters\nin the shell command output, use \\[universal-coding-system-argument] before this command.\n\nNoninteractive callers can specify coding systems by binding\n`coding-system-for-read' and `coding-system-for-write'.\n\nThe optional second argument OUTPUT-BUFFER, if non-nil,\nsays to put the output in some other buffer.\nIf OUTPUT-BUFFER is a buffer or buffer name, erase that buffer\nand insert the output there; a non-nil value of\n`shell-command-dont-erase-buffer' prevents the buffer from being\nerased.  If OUTPUT-BUFFER is not a buffer and not nil, insert the\noutput in current buffer after point leaving mark after it.  This\ncannot be done asynchronously.\n\nIf the command terminates without error, but generates output,\nand you did not specify \"insert it in the current buffer\",\nthe output can be displayed in the echo area or in its buffer.\nIf the output is short enough to display in the echo area\n(determined by the variable `max-mini-window-height' if\n`resize-mini-windows' is non-nil), it is shown there.\nOtherwise, the buffer containing the output is displayed.\n\nIf there is output and an error, and you did not specify \"insert it\nin the current buffer\", a message about the error goes at the end\nof the output.\n\nIf the optional third argument ERROR-BUFFER is non-nil, it is a buffer\nor buffer name to which to direct the command's standard error output.\nIf it is nil, error output is mingled with regular output.\nIn an interactive call, the variable `shell-command-default-error-buffer'\nspecifies the value of ERROR-BUFFER.\n\nIn Elisp, you will often be better served by calling `call-process' or\n`start-process' directly, since they offer more control and do not\nimpose the use of a shell (with its need to quote arguments)." (interactive #f(compiled-function () #<bytecode 0x2de6b45>)) #<bytecode 0x24f6ad>)("git submodule --quiet foreach 'echo $path' | tr '\\..." t nil)
  shell-command--shell-command-with-editor-mode(#f(compiled-function (command &optional output-buffer error-buffer) "Execute string COMMAND in inferior shell; display output, if any.\nWith prefix argument, insert the COMMAND's output at point.\n\nInteractively, prompt for COMMAND in the minibuffer.\n\nIf COMMAND ends in `&', execute it asynchronously.\nThe output appears in the buffer `*Async Shell Command*'.\nThat buffer is in shell mode.  You can also use\n`async-shell-command' that automatically adds `&'.\n\nOtherwise, COMMAND is executed synchronously.  The output appears in\nthe buffer `*Shell Command Output*'.  If the output is short enough to\ndisplay in the echo area (which is determined by the variables\n`resize-mini-windows' and `max-mini-window-height'), it is shown\nthere, but it is nonetheless available in buffer `*Shell Command\nOutput*' even though that buffer is not automatically displayed.\n\nTo specify a coding system for converting non-ASCII characters\nin the shell command output, use \\[universal-coding-system-argument] before this command.\n\nNoninteractive callers can specify coding systems by binding\n`coding-system-for-read' and `coding-system-for-write'.\n\nThe optional second argument OUTPUT-BUFFER, if non-nil,\nsays to put the output in some other buffer.\nIf OUTPUT-BUFFER is a buffer or buffer name, erase that buffer\nand insert the output there; a non-nil value of\n`shell-command-dont-erase-buffer' prevents the buffer from being\nerased.  If OUTPUT-BUFFER is not a buffer and not nil, insert the\noutput in current buffer after point leaving mark after it.  This\ncannot be done asynchronously.\n\nIf the command terminates without error, but generates output,\nand you did not specify \"insert it in the current buffer\",\nthe output can be displayed in the echo area or in its buffer.\nIf the output is short enough to display in the echo area\n(determined by the variable `max-mini-window-height' if\n`resize-mini-windows' is non-nil), it is shown there.\nOtherwise, the buffer containing the output is displayed.\n\nIf there is output and an error, and you did not specify \"insert it\nin the current buffer\", a message about the error goes at the end\nof the output.\n\nIf the optional third argument ERROR-BUFFER is non-nil, it is a buffer\nor buffer name to which to direct the command's standard error output.\nIf it is nil, error output is mingled with regular output.\nIn an interactive call, the variable `shell-command-default-error-buffer'\nspecifies the value of ERROR-BUFFER.\n\nIn Elisp, you will often be better served by calling `call-process' or\n`start-process' directly, since they offer more control and do not\nimpose the use of a shell (with its need to quote arguments)." (interactive #f(compiled-function () #<bytecode 0x11bf99d>)) #<bytecode 0x24f6ad>) "git submodule --quiet foreach 'echo $path' | tr '\\..." t)
  apply(shell-command--shell-command-with-editor-mode #f(compiled-function (command &optional output-buffer error-buffer) "Execute string COMMAND in inferior shell; display output, if any.\nWith prefix argument, insert the COMMAND's output at point.\n\nInteractively, prompt for COMMAND in the minibuffer.\n\nIf COMMAND ends in `&', execute it asynchronously.\nThe output appears in the buffer `*Async Shell Command*'.\nThat buffer is in shell mode.  You can also use\n`async-shell-command' that automatically adds `&'.\n\nOtherwise, COMMAND is executed synchronously.  The output appears in\nthe buffer `*Shell Command Output*'.  If the output is short enough to\ndisplay in the echo area (which is determined by the variables\n`resize-mini-windows' and `max-mini-window-height'), it is shown\nthere, but it is nonetheless available in buffer `*Shell Command\nOutput*' even though that buffer is not automatically displayed.\n\nTo specify a coding system for converting non-ASCII characters\nin the shell command output, use \\[universal-coding-system-argument] before this command.\n\nNoninteractive callers can specify coding systems by binding\n`coding-system-for-read' and `coding-system-for-write'.\n\nThe optional second argument OUTPUT-BUFFER, if non-nil,\nsays to put the output in some other buffer.\nIf OUTPUT-BUFFER is a buffer or buffer name, erase that buffer\nand insert the output there; a non-nil value of\n`shell-command-dont-erase-buffer' prevents the buffer from being\nerased.  If OUTPUT-BUFFER is not a buffer and not nil, insert the\noutput in current buffer after point leaving mark after it.  This\ncannot be done asynchronously.\n\nIf the command terminates without error, but generates output,\nand you did not specify \"insert it in the current buffer\",\nthe output can be displayed in the echo area or in its buffer.\nIf the output is short enough to display in the echo area\n(determined by the variable `max-mini-window-height' if\n`resize-mini-windows' is non-nil), it is shown there.\nOtherwise, the buffer containing the output is displayed.\n\nIf there is output and an error, and you did not specify \"insert it\nin the current buffer\", a message about the error goes at the end\nof the output.\n\nIf the optional third argument ERROR-BUFFER is non-nil, it is a buffer\nor buffer name to which to direct the command's standard error output.\nIf it is nil, error output is mingled with regular output.\nIn an interactive call, the variable `shell-command-default-error-buffer'\nspecifies the value of ERROR-BUFFER.\n\nIn Elisp, you will often be better served by calling `call-process' or\n`start-process' directly, since they offer more control and do not\nimpose the use of a shell (with its need to quote arguments)." (interactive #f(compiled-function () #<bytecode 0x10e4cb9>)) #<bytecode 0x24f6ad>) ("git submodule --quiet foreach 'echo $path' | tr '\\..." t))
  shell-command("git submodule --quiet foreach 'echo $path' | tr '\\..." t)
  shell-command-to-string("git submodule --quiet foreach 'echo $path' | tr '\\...")
  projectile-files-via-ext-command("/home/manuel/7bridges/code/gaypa-docs/conf/docker/..." "git submodule --quiet foreach 'echo $path' | tr '\\...")
  projectile-get-immediate-sub-projects("/home/manuel/7bridges/code/gaypa-docs/conf/docker/...")
  projectile-get-all-sub-projects("/home/manuel/7bridges/code/gaypa-docs/conf/docker/...")
  #f(compiled-function (s) #<bytecode 0x222a845>)("/home/manuel/7bridges/code/gaypa-docs/conf/docker/...")
  mapcar(#f(compiled-function (s) #<bytecode 0x222a845>) ("/home/manuel/7bridges/code/gaypa-docs/conf/docker/..."))
  projectile-get-all-sub-projects("/home/manuel/7bridges/code/gaypa-docs/")
  projectile-get-sub-projects-files("/home/manuel/7bridges/code/gaypa-docs/" git)
  projectile-dir-files-external("/home/manuel/7bridges/code/gaypa-docs/")
  projectile-dir-files("/home/manuel/7bridges/code/gaypa-docs/" "/home/manuel/7bridges/code/gaypa-docs/")
  #f(compiled-function (dir) #<bytecode 0x2172989>)("/home/manuel/7bridges/code/gaypa-docs/")
  mapcan(#f(compiled-function (dir) #<bytecode 0x2172989>) ("/home/manuel/7bridges/code/gaypa-docs/"))
  cl-mapcan(#f(compiled-function (dir) #<bytecode 0x2172989>) ("/home/manuel/7bridges/code/gaypa-docs/"))
  projectile-project-files("/home/manuel/7bridges/code/gaypa-docs/")
  projectile-current-project-files()
  counsel-projectile-find-file(nil)
  funcall-interactively(counsel-projectile-find-file nil)
  call-interactively(counsel-projectile-find-file nil nil)
  command-execute(counsel-projectile-find-file)

Steps to reproduce the problem

Given a project with at least a Git submodule in it, run projectile-find-file.

Environment & Version information

GNU Emacs 27.0.50 (build 1, x86_64-debian-linux-gnu, GTK+ Version 3.22.30)
 of 2018-10-01

Repository revision: 87d0007499d8434f40926c99f1edc3c4a700a79d
Configured using:
--host=x86_64-debian-linux-gnu --with-modules

Emacs uptime: 11 minutes, 27 seconds
Colour theme: sanityinc-tomorrow-night
Operating system: Ubuntu 18.04.1 LTS
Window system: x11
Desktop environment: GNOME Shell 3.28.3

Projectile version information

Projectile 20180930.1853
Bug

Most helpful comment

As a workaround, set projectile-git-submodule-command to nil.

All 17 comments

Further info. If I run the command specified in projectile-git-submodule-command via the command line, I get:

~/7bridges/code/gaypa-docs/docker dev* 
❯ git submodule --quiet foreach 'echo $path' | tr '\\n' '\\0'
rest-api-explorer

Which is correct.

I likely broke this during my massive round of refactoring over the weekend. I try to investigate it later this week. My assumption is that some default-directory binding I deleted was probably required for this to work. I've been trying to reduce the need for dynamic var bindings and make the API more in line with modern development practices (explicit param passing everywhere). Unfortunately the codebase is relatively big and dynamic bindings were used pretty much everywhere for a very long time...

Might be a good idea to step through the code and see what's the default-directory when this shell-command gets executed.

Please check if PR #1308 fixes your issue.

Thanks @DamienCassou, it works fine now.

I'm having a very similar issue. Error given is this

In ‘Projectile files’ source: ‘#[0 \301 \205;r\302!\203\206p\211q\210\303 \304 \305\211:\2036@\262\306"BB\262A\262\202\211\237\266\204)\207 [helm-current-buffer projectile-project-p buffer-live-p projectile-project-root projectile-current-project-files nil expand-file-name] 8]’ 
 (file-error "Setting current directory" "No such file or directory" "<path-to-project-root>/’tr’ is not recognized as an internal or external command,
operable program or batch file.
/")

Backtrace is hard to copy here since it clears everytime I try to focus on the buffer, but the gist of it is that it happens in process-file -> shell-command-to-string -> projectile-files-via-ext-command -> projectile-get-immediate-sub-projects -> projectile-get-all-sub-projects -> projectile-get-sub-projects-files -> ....

It seems that projectile is not finding tr (works fine in a PowerShell terminal), and the error message it gets from that is being used as a file name.

I've tried the above fix but to no avail (it's possible I'm doing something wrong, just edited the file manually and byte compiled the file). I also tried removing the tr pipe, but no luck either.

I'm on Windows 10 and using spacemacs.

After trying M-x projectile-find-file I get

apply: Setting current directory: No such file or directory, /home/tima/build/the_silver_searcher/bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell

The path "/home/tima/build/the_silver_searcher/bash" is, indeed, incorrect: "bash" is added to the root of the project.

projectile-20181015.1723

This doesn't seem to be fixed for me with Projectile 20181028.838 in GNU Emacs 26.1 (build 1, x86_64-w64-mingw32) of 2018-05-30

Running on Windows 10.

I get error:

apply: Setting current directory: No such file or directory, c:/workplace/logic/'tr' is not recognized as an internal or external command, operable program or batch file.apply: Setting current directory: No such file or directory, c:/workplace/logic/'tr' is not recognized as an internal or external command, operable program or batch file.

When running projectile-find-file or counsel-projectile-switch-project.

As a workaround, set projectile-git-submodule-command to nil.

I (emacs user) was helping my co-worker setup spacemacs for the first time, and we were getting the error in a project _without_ submodules. @altschuler fix above worked perfectly, thanks for saving my sanity

I am experiencing the same issue on Windows 10 with GNU Emacs 26.1.

apply: Setting current directory: No such file or directory, c:/Users/admin/AppData/Roaming/.emacs.d/error: no program name specified.

and M-x counsel-projectile-find-file got this error:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("^/tmp_mnt/" nil)
  abbreviate-file-name(nil)
  projectile-locate-dominating-file(nil ".git")
  projectile-project-vcs()
  projectile-get-repo-files()
  projectile-dir-files-external(nil "")
  projectile-dir-files(nil "")
  #f(compiled-function (dir) #<bytecode 0x3105c81>)("")
  mapcan(#f(compiled-function (dir) #<bytecode 0x3105c81>) (""))
  cl-mapcan(#f(compiled-function (dir) #<bytecode 0x3105c81>) (""))
  projectile-project-files(nil)
  projectile-current-project-files()
  counsel-projectile-find-file(nil)
  funcall-interactively(counsel-projectile-find-file nil)
  call-interactively(counsel-projectile-find-file nil nil)
  command-execute(counsel-projectile-find-file)

Confirm: the issue disappear in the latest version. And the workaround (setq projectile-git-submodule-command nil) works as well.

Confirm: the issue disappear in the latest version. And the workaround (setq projectile-git-submodule-command nil) works as well.

It works on Windows 10 with GNU Emacs 25.3

Confirm: the issue disappear in the latest version. And the workaround (setq projectile-git-submodule-command nil) works as well.

It works on Windows 10 with GNU Emacs 25.3

Do you have tr installed on Windows 10 somehow? I'm still seeing the issue.

I'm possibly seeing an upstream issue here, but the (setq projectile-git-submodule-command nil) workaround is effective:

git submodule --quiet foreach 'echo $path' | tr '\\n' '\\0'
# GNU gettext shell script function library version 0.19.8.1
# Usage: . gettext.sh
git submodule 
# GNU gettext shell script function library version 0.19.8.1
# Usage: . gettext.sh

git --version
# git version 2.21.0

gettext --version
# gettext (GNU gettext-runtime) 0.19.8.1
# Copyright (C) 1995-1997, 2000-2007 Free Software Foundation, Inc.

Update:

Worked around this issue without setting (setq projectile-git-submodule-command nil) by installing gettext using homebrew and adding it to PATH:

% brew install gettext
% export PATH="/usr/local/opt/gettext/bin:$PATH"

% git submodule
 3f2bb2d2401cf5876fc2d806ecab462984619a79 home/spacemacs.d/layers/w3m (heads/master)
 734d9a11b5a6354e6a66e152dee5d311233e033c home/vim/vim-plug (0.9.1-84-g734d9a1)
 9a06c28ddc2c6efbabc0e4d5806d89b0d63c8b8e home/zsh/zsh-syntax-highlighting (0.6.0-223-g9a06c28)

🤔

Confirm: the issue disappear in the latest version. And the workaround (setq projectile-git-submodule-command nil) works as well.

It works on Windows 10 with GNU Emacs 25.3

Do you have tr installed on Windows 10 somehow? I'm still seeing the issue.

I install tr by install gitforWin.

@jmromer 's solution of adding gettext to the path worked for me in the current spacemacs develop branch. (I'm also on OSX)

Was this page helpful?
0 / 5 - 0 ratings