twosigma / git-meta

Repository for the git-meta project -- build your own monorepo using Git submodules
http://twosigma.github.io/git-meta
BSD 3-Clause "New" or "Revised" License
218 stars 50 forks source link

git meta add-submodule => failed to make directory #674

Open jokram opened 5 years ago

jokram commented 5 years ago

When trying to add a new submodule to a repository having no submodules then I'll always get the following error:

$ git meta add-submodule -i file:///d/casdev/_test/git-meta/try/arepo.git file:///d/casdev/_test/git-meta/try/arepo.git src/arepo
Error: failed to make directory 'D:\casdev\_test\git-meta\try\metarepo\.git\modules\src\arepo': Das System kann den angegebenen Pfad nicht finden.

Is it because I'm having Windows?

This is the script I've used to check if I'm making something wrong: https://gist.github.com/dhbaird/a7137b3fa012cb88c3cb64c1a201d4d2:

Here is the full output of that script:

$ ./try.sh
++ pwd
+ D=/d/casdev/_test/git-meta/try
+ banner Git-meta acceptance script
+ set +x

--------------------------
Git-meta acceptance script
--------------------------

+ banner Cleanup previous runs
+ set +x

---------------------
Cleanup previous runs
---------------------

+ rm -rf 'arepo*/'
+ rm -rf 'brepo*/'
+ rm -rf 'metarepo*/'
+ banner Build initial repositories
+ set +x

--------------------------
Build initial repositories
--------------------------

+ git init --bare arepo.git
Initialized empty Git repository in d:/casdev/_test/git-meta/try/arepo.git/
+ git init --bare brepo.git
Initialized empty Git repository in d:/casdev/_test/git-meta/try/brepo.git/
+ git init --bare metarepo.git
Initialized empty Git repository in d:/casdev/_test/git-meta/try/metarepo.git/
+ git clone arepo.git arepo
Cloning into 'arepo'...
warning: You appear to have cloned an empty repository.
done.
+ git clone brepo.git brepo
Cloning into 'brepo'...
warning: You appear to have cloned an empty repository.
done.
+ git clone metarepo.git metarepo
Cloning into 'metarepo'...
warning: You appear to have cloned an empty repository.
done.
+ pushd arepo
+ echo A
+ git add README.md
+ git commit -m 'Add README to arepo.'
[master (root-commit) b58a139] Add README to arepo.
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
+ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 251 bytes | 251.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To d:/casdev/_test/git-meta/try/arepo.git
 * [new branch]      master -> master
+ popd
+ pushd metarepo
+ echo M
+ git add README.md
+ git commit -m 'Add README to metarepo.'
[master (root-commit) b3e1896] Add README to metarepo.
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
+ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 254 bytes | 254.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To d:/casdev/_test/git-meta/try/metarepo.git
 * [new branch]      master -> master
+ popd
+ banner Import arepo into metarepo
+ set +x

--------------------------
Import arepo into metarepo
--------------------------

+ pushd metarepo
+ git meta add-submodule -i file:///d/casdev/_test/git-meta/try/arepo.git file:///d/casdev/_test/git-meta/try/arepo.git src/arepo
Error: failed to make directory 'D:\casdev\_test\git-meta\try\metarepo\.git\modules\src\arepo': Das System kann den angegebenen Pfad nicht finden.
novalis commented 5 years ago

Thanks for the detailed report. I just ran your script on Debian, and it works fine, so I am extremely tempted to blame Windows. I don't have a Windows machine set up for testing, and our company does next to no development on Windows, so it's not surprising that there are some issues there.

Based on a quick grep, that error message probably comes from libgit2 (which we use via NodeGit). But I think it's in a utility method that's used all over the place, so I can't give any more specific debugging information.

We would happily accept bug fixes for Windows, if you happen to want to write some.

novalis commented 5 years ago

BTW, I notice that you are adding a README.md file to the meta repository. We have no files (other than .gitmodules) in our meta repo, and git-meta has some code that assumes that there are only submodules, without any files, in the meta repo. So you might run into an issue if you do that (but that is probably not the cause of this bug specifically).