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

Providing a token to cargo login via command line causes a hang on CI #12438

Closed
DrChat opened this issue Aug 2, 2023 · 1 comment · Fixed by #12440
Closed

Providing a token to cargo login via command line causes a hang on CI #12438

DrChat opened this issue Aug 2, 2023 · 1 comment · Fixed by #12440
Labels
C-bug Category: bug Command-login P-high Priority: High regression-from-stable-to-nightly Regression in nightly that previously worked in stable. S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@DrChat
Copy link

DrChat commented Aug 2, 2023

Problem

Specifying the logon token via the command-line will cause a hang if stdin is not attached to a terminal (such as when running in automation).

Steps

cargo login --registry xxxxxxxx "Bearer XXXXXXXXXXXXXXXXXXXXXXXXX"

Possible Solution(s)

Workaround:

"Bearer XXXXXXXXXXXXXXXXXXXXXXXXX" | cargo login --registry xxxxxxxx

Notes

Likely introduced by #12334:

if !std::io::stdin().is_terminal() {
let token = std::io::read_to_string(std::io::stdin()).unwrap_or_default();
if !token.is_empty() {
token_from_stdin = Some(token);
}
}
let token = token_from_cmdline.or_else(|| token_from_stdin.as_deref().map(Secret::from));

Version

cargo 1.73.0-nightly (c91a693e7 2023-07-31)
release: 1.73.0-nightly
commit-hash: c91a693e7977e33a1064b63a5daf5fb689f01651
commit-date: 2023-07-31
host: x86_64-unknown-linux-gnu
libgit2: 1.6.4 (sys:0.17.2 vendored)
libcurl: 8.2.1-DEV (sys:0.4.65+curl-8.2.1 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Ubuntu 20.04 (focal) [64-bit]
@DrChat DrChat added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Aug 2, 2023
@ehuss ehuss added P-high Priority: High Command-login S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review regression-from-stable-to-nightly Regression in nightly that previously worked in stable. and removed S-triage Status: This issue is waiting on initial triage. labels Aug 2, 2023
@ehuss
Copy link
Contributor

ehuss commented Aug 2, 2023

@arlosi Do you have a chance to look at this? I think an easy change would be to move the is_terminal check into the or_else closure.

I'm a bit unclear why CI has a stdin that isn't /dev/null and isn't a terminal. I would expect non-terminal stdin to immediately return an empty input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Command-login P-high Priority: High regression-from-stable-to-nightly Regression in nightly that previously worked in stable. S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants