projectile icon indicating copy to clipboard operation
projectile copied to clipboard

Error when using git submodules with projectile

Open sonictk opened this issue 5 years ago • 4 comments

Expected behavior

That projectile-find-file works.

Actual behavior

I get an error. It seems like formatting of the final command to call has a bug with it on Windows:

Debugger entered--Lisp error: (file-missing "Setting current directory" #("No such file or directory" 0 25 (charset windows-1252)) "c:/Users/REDACTED/Git/REDACTED/'echo: -c: line 0: unexpe...")
  call-process("C:/emacs27_1/libexec/emacs/27.1/x86_64-w64-mingw32..." nil t nil "-c" "git submodule --quiet foreach 'echo $path' | tr '\\...")
  call-process-shell-command("git submodule --quiet foreach 'echo $path' | tr '\\..." nil t)
  shell-command("git submodule --quiet foreach 'echo $path' | tr '\\..." t)
  shell-command-to-string("git submodule --quiet foreach 'echo $path' | tr '\\...")
  (split-string (shell-command-to-string command) "\0" t)
  (let ((default-directory root)) (split-string (shell-command-to-string command) "\0" t))
  (progn (let ((default-directory root)) (split-string (shell-command-to-string command) "\0" t)))
  (if (stringp command) (progn (let ((default-directory root)) (split-string (shell-command-to-string command) "\0" t))))
  projectile-files-via-ext-command("c:/Users/REDACTED/Git/REDACTED/'echo: -c: line 0: unexpe..." "git submodule --quiet foreach 'echo $path' | tr '\\...")
  (mapcar #'(lambda (s) (file-name-as-directory (expand-file-name s path))) (projectile-files-via-ext-command path (projectile-get-sub-projects-command vcs)))
  (let* ((vcs (projectile-project-vcs path)) (submodules (mapcar #'(lambda (s) (file-name-as-directory (expand-file-name s path))) (projectile-files-via-ext-command path (projectile-get-sub-projects-command vcs)))) (project-child-folder-regex (concat "\\`" (regexp-quote path)))) (cl-remove-if-not #'(lambda (submodule) (string-match-p project-child-folder-regex submodule)) submodules))
  projectile-get-immediate-sub-projects("c:/Users/REDACTED/Git/REDACTED/'echo: -c: line 0: unexpe...")
  (let ((submodules (projectile-get-immediate-sub-projects project))) (cond ((null submodules) nil) (t (nconc submodules (projectile-flatten (mapcar #'(lambda ... ...) submodules))))))
  projectile-get-all-sub-projects("c:/Users/REDACTED/Git/REDACTED/'echo: -c: line 0: unexpe...")
  (closure ((submodules "c:/Users/REDACTED/Git/REDACTED/'echo: -c: line 0: unexpe...") (project . "c:/Users/REDACTED/Git/REDACTED/") t) (s) (projectile-get-all-sub-projects s))("c:/Users/REDACTED/Git/REDACTED/'echo: -c: line 0: unexpe...")
  mapcar((closure ((submodules "c:/Users/REDACTED/Git/REDACTED/'echo: -c: line 0: unexpe...") (project . "c:/Users/REDACTED/Git/REDACTED/") t) (s) (projectile-get-all-sub-projects s)) ("c:/Users/REDACTED/Git/REDACTED/'echo: -c: line 0: unexpe..."))
  (projectile-flatten (mapcar #'(lambda (s) (projectile-get-all-sub-projects s)) submodules))
  (nconc submodules (projectile-flatten (mapcar #'(lambda (s) (projectile-get-all-sub-projects s)) submodules)))
  (cond ((null submodules) nil) (t (nconc submodules (projectile-flatten (mapcar #'(lambda (s) (projectile-get-all-sub-projects s)) submodules)))))
  (let ((submodules (projectile-get-immediate-sub-projects project))) (cond ((null submodules) nil) (t (nconc submodules (projectile-flatten (mapcar #'(lambda ... ...) submodules))))))
  projectile-get-all-sub-projects("c:/Users/REDACTED/Git/REDACTED/")
  (mapcar #'(lambda (sub-project) (let ((project-relative-path (file-name-as-directory (file-relative-name sub-project project-root)))) (mapcar #'(lambda (file) (concat project-relative-path file)) (projectile-files-via-ext-command sub-project projectile-git-command)))) (projectile-get-all-sub-projects project-root))
  (projectile-flatten (mapcar #'(lambda (sub-project) (let ((project-relative-path (file-name-as-directory ...))) (mapcar #'(lambda ... ...) (projectile-files-via-ext-command sub-project projectile-git-command)))) (projectile-get-all-sub-projects project-root)))
  projectile-get-sub-projects-files("c:/Users/REDACTED/Git/REDACTED/" git)
  (nconc (projectile-files-via-ext-command directory (projectile-get-ext-command vcs)) (projectile-get-sub-projects-files directory vcs))
  (cond ((eq vcs 'git) (nconc (projectile-files-via-ext-command directory (projectile-get-ext-command vcs)) (projectile-get-sub-projects-files directory vcs))) (t (projectile-files-via-ext-command directory (projectile-get-ext-command vcs))))
  (let ((vcs (projectile-project-vcs directory))) (cond ((eq vcs 'git) (nconc (projectile-files-via-ext-command directory (projectile-get-ext-command vcs)) (projectile-get-sub-projects-files directory vcs))) (t (projectile-files-via-ext-command directory (projectile-get-ext-command vcs)))))
  projectile-dir-files-alien("c:/Users/REDACTED/Git/REDACTED/")
  (if (eq projectile-indexing-method 'alien) (projectile-dir-files-alien project-root) (cl-mapcan #'(lambda (dir) (mapcar #'(lambda (f) (file-relative-name ... project-root)) (projectile-dir-files dir))) (projectile-get-project-directories project-root)))
  (setq files (if (eq projectile-indexing-method 'alien) (projectile-dir-files-alien project-root) (cl-mapcan #'(lambda (dir) (mapcar #'(lambda ... ...) (projectile-dir-files dir))) (projectile-get-project-directories project-root))))
  (progn (if projectile-enable-caching (progn (message "Projectile is initializing cache for %s ..." project-root))) (setq files (if (eq projectile-indexing-method 'alien) (projectile-dir-files-alien project-root) (cl-mapcan #'(lambda (dir) (mapcar #'... (projectile-dir-files dir))) (projectile-get-project-directories project-root)))) (if projectile-enable-caching (progn (projectile-cache-project project-root files))))
  (if (null files) (progn (if projectile-enable-caching (progn (message "Projectile is initializing cache for %s ..." project-root))) (setq files (if (eq projectile-indexing-method 'alien) (projectile-dir-files-alien project-root) (cl-mapcan #'(lambda (dir) (mapcar ... ...)) (projectile-get-project-directories project-root)))) (if projectile-enable-caching (progn (projectile-cache-project project-root files)))))
  (let (files) (if projectile-files-cache-expire (progn (let ((cache-time (gethash project-root projectile-projects-cache-time))) (if (or (null cache-time) (< (+ cache-time projectile-files-cache-expire) (projectile-time-seconds))) (progn (remhash project-root projectile-projects-cache) (remhash project-root projectile-projects-cache-time)))))) (if projectile-enable-caching (progn (setq files (gethash project-root projectile-projects-cache)))) (if (null files) (progn (if projectile-enable-caching (progn (message "Projectile is initializing cache for %s ..." project-root))) (setq files (if (eq projectile-indexing-method 'alien) (projectile-dir-files-alien project-root) (cl-mapcan #'(lambda ... ...) (projectile-get-project-directories project-root)))) (if projectile-enable-caching (progn (projectile-cache-project project-root files))))) (if (eq projectile-indexing-method 'alien) files (projectile-sort-files files)))
  projectile-project-files("c:/Users/REDACTED/Git/REDACTED/")
  (projectile-completing-read "Find file: " (projectile-project-files project-root))
  (let* ((project-root (projectile-ensure-project (projectile-project-root))) (file (projectile-completing-read "Find file: " (projectile-project-files project-root))) (ff (or ff-variant #'find-file))) (if file (progn (funcall ff (expand-file-name file project-root)) (run-hooks 'projectile-find-file-hook))))
  projectile--find-file(nil)
  projectile-find-file(nil)
  funcall-interactively(projectile-find-file nil)
  call-interactively(projectile-find-file nil nil)
  command-execute(projectile-find-file)

Steps to reproduce the problem

  • On Windows, have a git repository with a submodule in it and attempt to call projectile-find-file.

Environment & Version information

  • Windows 10
  • Emacs 27.1
  • Latest projectile.el (2.3.0snapshot)

Projectile version information

- Latest `projectile.el` (2.3.0snapshot)

Emacs version

27.1 x86_64-w64-mingw32

Operating system

Windows 10

sonictk avatar Nov 17 '20 11:11 sonictk

Probably the git command invoked here has to be adjusted for Windows:

Debugger entered--Lisp error: (file-missing "Setting current directory" #("No such file or directory" 0 25 (charset windows-1252)) "c:/Users/REDACTED/Git/REDACTED/'echo: -c: line 0: unexpe...")
  call-process("C:/emacs27_1/libexec/emacs/27.1/x86_64-w64-mingw32..." nil t nil "-c" "git submodule --quiet foreach 'echo $path' | tr '\\...")
  call-process-shell-command("git submodule --quiet foreach 'echo $path' | tr '\\..." nil t)

It seems something from the error message is missing, though - c: line 0: unexpe..."

bbatsov avatar Nov 24 '20 15:11 bbatsov

It seems something from the error message is missing, though - c: line 0: unexpe..."

Hmm, I only redacted the actual parts that say REDACTED. I'll try running the commands directly in the shell to see what the full output of that error should be.

I also noticed that if I first initialize the projectile cache, then add the submodule, this issue doesn't seem to occur; but if I first clone down my repository with its submodule and then try to initialize the projectile cache, this issue is triggered.

sonictk avatar Dec 04 '20 19:12 sonictk

It seems to me that this is the command:

shell-command("git submodule --quiet foreach 'echo $path' | tr '\\..." t)

bbatsov avatar Dec 04 '20 19:12 bbatsov

I think the rest of the message is probably the unexpected EOF message...

λ git submodule --quiet foreach 'echo $path' | tr '\\...
tr: missing operand after ‘\\...’
Two strings must be given when translating.
Try 'tr --help' for more information.
'echo: -c: line 0: unexpected EOF while looking for matching `''
'echo: -c: line 1: syntax error: unexpected end of file
fatal: run_command returned non-zero status for thirdparty/imgui
.

sonictk avatar Dec 04 '20 23:12 sonictk