You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose the template to generate from is in a repository b that has a git submodule a as a dependency.
So the repository b looks like the following (assuming ahas a filefoo`).
├── b
│ └── a
│ └── foo
Now suppose we wish to initialize a project using cargo generate in /root where
/root
└── a
└── somefile
that is, root has a non-empty subdirectory called a.
This fails with the error.
Caused by:
'a' exists and is not an empty directory; class=Invalid (3); code=Exists (-4)
To Reproduce
Steps to reproduce the behavior:
cargo generate <WHAT DID YOU RUN>
output it generated..
See error
Expected behavior
cargo generate succeeds and offers the usual options.
Desktop (please complete the following information):
OS: Linux
Version: v0.5.0-453-g51deb01
Build tools: gcc
cargo generate --version: 0.17.4
** Root cause **
The root cause of this is the following issue in libgit2libgit2/libgit2#5830 .
Essentially during the cloning of the submodule there is an incorrect check which checks in the current working directory whether the directory a exists even though that is not relevant.
It is possible to work around the issue in cargo-generate by modifying the clone_with_submodules function to change the working directory
pubfnclone_with_submodules(self,dest_path:&Path) -> Result<Repository>{self.clone(dest_path).and_then(|repo| {// set the working directory to the root of the newly created repository// this works around the issue https://github.com/libgit2/libgit2/issues/5830// in libgit2
std::env::set_current_dir(dest_path)?;formut sub in repo.submodules()? {
sub.update(true,None)?;}Ok(repo)})}
Seeing that the libgit2 has not resolved the issue in more than a year, would it be acceptable to this project to work around the issue here? I'm more than happy to contribute a PR.
The text was updated successfully, but these errors were encountered:
I guess the proposed workaround is fine, but IMO it is important to restore the CWD to it's previous value in order to minimize side effects as much as possible.
Update: feel free and very welcome to open a PR for it.
Describe the bug
Suppose the template to generate from is in a repository
b
that has a git submodulea
as a dependency.So the repository
b looks like the following (assuming
ahas a file
foo`).Now suppose we wish to initialize a project using
cargo generate
in/root
wherethat is,
root
has a non-empty subdirectory calleda
.This fails with the error.
To Reproduce
Steps to reproduce the behavior:
cargo generate <WHAT DID YOU RUN>
Expected behavior
cargo generate
succeeds and offers the usual options.Desktop (please complete the following information):
v0.5.0-453-g51deb01
cargo generate --version
: 0.17.4** Root cause **
The root cause of this is the following issue in
libgit2
libgit2/libgit2#5830 .Essentially during the cloning of the submodule there is an incorrect check which checks in the current working directory whether the directory
a
exists even though that is not relevant.It is possible to work around the issue in cargo-generate by modifying the
clone_with_submodules
function to change the working directorySeeing that the libgit2 has not resolved the issue in more than a year, would it be acceptable to this project to work around the issue here? I'm more than happy to contribute a PR.
The text was updated successfully, but these errors were encountered: