Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo new fails with side effect when $USER env variable is not set #8783

Closed
nixphix opened this issue Oct 15, 2020 · 1 comment · Fixed by rust-lang/rust#79820
Closed

Cargo new fails with side effect when $USER env variable is not set #8783

nixphix opened this issue Oct 15, 2020 · 1 comment · Fixed by rust-lang/rust#79820
Labels

Comments

@nixphix
Copy link

nixphix commented Oct 15, 2020

Problem
When running cargo new foo in the vscode built-in terminal it fails with error $USER env variable is not set but it does so after initializing the package repository foo so now I have repo created but it is not initialized

└── foo
    ├── .git
    └── .gitignore

The expectation is if the command fails there should be no side effect, no folder or git repo created.

Steps

  1. unset USER
  2. cargo new foo
  3. ls

Possible Solution(s)
discover_author bails when $USER is not found, so it should be called before init_vcs

Notes

Output of cargo version:
cargo 1.47.0 (f3c7e066a 2020-08-28)

@nixphix nixphix added the C-bug Category: bug label Oct 15, 2020
@ehuss
Copy link
Contributor

ehuss commented Oct 20, 2020

I would also suggest that it could maybe query the operating system for the username. Or, it could just not fill out the authors field and print a warning or something.

bors added a commit that referenced this issue Dec 3, 2020
Fixes #8783 , cargo new fails without a author name or email

If user can not be obtained from git or env variables $USER, new command defaults to empty author in generated Cargo.toml

Could not edit old PR(#8910 8783) as the original clone was deleted.
@bors bors closed this as completed in 15f2cdb Dec 3, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 8, 2020
Update cargo

10 commits in 63d0fe43449adcb316d34d98a982b597faca4178..d274fcf862b89264fa2c6b917b15230705257317
2020-12-02 01:44:30 +0000 to 2020-12-07 23:08:44 +0000
- Clarify cargo manifest edition field docs (rust-lang/cargo#8953)
- Run rustdoc doctests relative to the workspace (rust-lang/cargo#8954)
- Workaround fs issue in `cargo publish`. (rust-lang/cargo#8950)
- Fix panic with -Zbuild-std and no roots. (rust-lang/cargo#8942)
- Slightly optimize `cargo vendor` (rust-lang/cargo#8937)
- Fixes rust-lang/cargo#8783 , cargo new fails without a author name or email (rust-lang/cargo#8912)
- Fix test escaping __CARGO_TEST_ROOT (rust-lang/cargo#8929)
- Add period to allowed feature name characters. (rust-lang/cargo#8932)
- faq: small fixes (rust-lang/cargo#8931)
- Fix semver documentation tests. (rust-lang/cargo#8930)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants