diff --git a/src/index/git_remote.rs b/src/index/git_remote.rs index 76e701d..5726c61 100644 --- a/src/index/git_remote.rs +++ b/src/index/git_remote.rs @@ -89,6 +89,19 @@ impl RemoteGitIndex { let res = if let Some(repo) = repo { (repo, None) } else { + // We need to create the directory chain ourselves, gix will fail + // if any parent directory is missing + if !index.cache.path.exists() { + std::fs::create_dir_all(&index.cache.path).map_err(|source| { + GitError::ClonePrep(Box::new(gix::clone::Error::Init( + gix::init::Error::Init(gix::create::Error::CreateDirectory { + source, + path: index.cache.path.clone().into(), + }), + ))) + })?; + } + let (repo, out) = gix::prepare_clone_bare(index.url.as_str(), &index.cache.path) .map_err(Box::new)? .with_remote_name("origin") diff --git a/tests/git.rs b/tests/git.rs index 7f5ff1c..210e0b3 100644 --- a/tests/git.rs +++ b/tests/git.rs @@ -12,7 +12,7 @@ fn remote_index( RemoteGitIndex::new( GitIndex::new(IndexLocation { url: IndexUrl::NonCratesIo(url.as_ref().as_str().into()), - root: IndexPath::Exact(path.as_ref().to_owned()), + root: IndexPath::Exact(path.as_ref().join("sub/dir")), }) .unwrap(), &utils::unlocked(),