Projectile: Error switching to project containing nested git repos

Created on 10 Oct 2018  Â·  11Comments  Â·  Source: bbatsov/projectile

Expected behavior

It should be possible to switch to a project containing nested git repos that are not submodules (e.g. it should treat the inner repos the same as any other subfolder within a project).

_Example_: My dotfiles repo has this structure due to installed vim packages being nested git repos.

Actual behavior

When attempting to switch to such a project, it fails and the following error is seen:

apply: Setting current directory: No such file or directory, /Users/siddhartha/work/sandbox/testtest/my-project/fatal: no submodule mapping found in .gitmodules for path 'inner-project'
inner-project/

Steps to reproduce the problem

  1. In a folder for testing, perform the following steps (or just paste this code into the shell):
mkdir my-project
cd my-project
mkdir inner-project
cd inner-project
git init
touch file1.txt
git add file1.txt
git commit -m "a file"
cd ..
git init
touch project-file.txt
git add project-file.txt
git commit -m "a file"
git add -A
git commit -m "add inner repo"
  1. Open a file in the project (i.e. my-project/project-file.txt) using emacs
  2. Switch to another project
  3. Attempt to switch back to the my-project project. It fails with the above error.

Environment & Version information

Projectile version information

Projectile 20181009.851

Note: the issue is not present in Projectile 1.0.0

Emacs version

GNU Emacs 26.1 (build 1, x86_64-apple-darwin17.6.0, Carbon Version 158 AppKit 1561.4)
of 2018-09-10

Operating system

MacOS High Sierra 10.13.5

Bug Stale

Most helpful comment

I had a similar issue, which might be related, where I have a GIT repository with multiple sub modules and within that GIT repository I've marked one specific sub directory as a project. Projectile, after the recent ranges, want the sub module paths relative to the project directory but the default sub module command set gets them relative to the GIT top level directory which causes an issue.

Workaround/solution to that was to change the sub module command.

(setq projectile-git-submodule-command "git submodule --quiet foreach 'echo $(git rev-parse --show-toplevel)' | xargs realpath --relative-to=$PWD"))

All 11 comments

Likely I've broken something with my recent refactorings. I'm a bit busy the next couple of weeks, but you can help me out if you'd like to debug where exactly the problem is. See http://www.projectile.mx/en/latest/troubleshooting/ for details.

Coincidentally I was on the lookout for a good edebug tutorial, thanks for the pointer. I'll share my findings in a PR soon.

I had a similar issue, which might be related, where I have a GIT repository with multiple sub modules and within that GIT repository I've marked one specific sub directory as a project. Projectile, after the recent ranges, want the sub module paths relative to the project directory but the default sub module command set gets them relative to the GIT top level directory which causes an issue.

Workaround/solution to that was to change the sub module command.

(setq projectile-git-submodule-command "git submodule --quiet foreach 'echo $(git rev-parse --show-toplevel)' | xargs realpath --relative-to=$PWD"))

I have a bit similar issue, in Node/NPM project my package.json lacks "license" key,

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-missing "Setting current directory" "No such file or directory" "/Users/argunovaleksandr/work/landing/warning package.json: No license field

Maybe it'd help with the fix.

@enordstrm I'm having the exact same issue. Your solution doesn't quite seem to work for me - in particular, I still get the same "No such file or directory" complaint even though the path now seems to be valid. Additionally, changing projectile-git-submodule-command like that causes problems in projects _without_ submodules.

Are you still using the same workaround, or have you made updates/changes since the original post? Thanks!

It looks like 614e7dbf44459ff81d80b4a409bd958ea7c60cc1 was meant to address this? But that's the version of Projectile I'm using, and I still see the issue.

I'm seeing the same issue as enordstrm. A quick workaround for git repos with no submodules, is to redirect stderr to /dev/null:
(setq projectile-git-submodule-command "git submodule --quiet foreach 'echo $(git rev-parse --show-toplevel)' | xargs realpath --relative-to=$PWD 2> /dev/null")

I'm not sure if I should make a separate issue or post here, but mine is following and only happens when I use projectile-find-file:

apply: Setting current directory: No such file or directory, /path/to/dir * Error: Problem adding; giving up

On the other hand, projectile-find-file-in-known-projects works fine.

It definitely has something to do with git submodules, because setting projectile-git-submodule-command to nil fixes the issue for me. The workaround mentioned by @spaceotter doesn't help.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

This issues been automatically closed due to lack of activity. Feel free to re-open it if you ever come back to it.

I have exactly the same after adding and removing a submodule.

I'm not sure if I should make a separate issue or post here, but mine is following and only happens when I use ¯projectile-find-file:

apply: Setting current directory: No such file or directory, /path/to/dir * Error: Problem adding; giving up

On the other hand, projectile-find-file-in-known-projects works fine.

It definitely has something to do with git submodules, because setting projectile-git-submodule-command to nil fixes the issue for me. The workaround mentioned by @spaceotter doesn't help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rrudakov picture rrudakov  Â·  4Comments

anderspapitto picture anderspapitto  Â·  5Comments

ghost picture ghost  Â·  4Comments

levicole picture levicole  Â·  3Comments

bomgar picture bomgar  Â·  4Comments