Skip to content

cargo new failed to detect vcs if parent of path does not exist #10981

@zhoukezi

Description

@zhoukezi

Problem

cargo new checks if the path of new package is inside a vcs repo. If there is one, it skips vcs initialize. However, if the parent of the package path does not exist, it failed to discover existing repo and initialize vsc redundantly.

Steps

Initialize git in an empty directory:

$ /bin/ls -a
.  ..
$ git init
Initialized empty Git repository in <path>/.git/

Create package in ./hello/world, note that ./hello/ does not exist:

$ cargo +nightly new hello/world
     Created binary (application) `hello/world` package
$ ls -d hello/world/.git
hello/world/.git

Create package in ./hello/rust, ./hello/ is create by previous cargo new call:

$ cargo +nightly new hello/rust
     Created binary (application) `hello/rust` package
$ ls -d hello/rust/.git
ls: cannot access 'hello/rust/.git': No such file or directory

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.65.0-nightly (ce40690a5 2022-08-09)
release: 1.65.0-nightly
commit-hash: ce40690a5e4e315d3dab0aae1eae69d0252c52ac
commit-date: 2022-08-09
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:OpenSSL/1.1.1q)
os: Arch Linux Rolling Release [64-bit]

Metadata

Metadata

Assignees

Labels

A-gitArea: anything dealing with gitA-vcsArea: general VCS issuesC-bugCategory: bugCommand-newS-blocked-externalStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions