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 build fails when ~/.cargo/credentials is unreadable #7624

Closed
RalfJung opened this issue Nov 23, 2019 · 1 comment · Fixed by #7774
Closed

cargo build fails when ~/.cargo/credentials is unreadable #7624

RalfJung opened this issue Nov 23, 2019 · 1 comment · Fixed by #7774
Labels
A-configuration Area: cargo config files and env vars C-bug Category: bug

Comments

@RalfJung
Copy link
Member

RalfJung commented Nov 23, 2019

Problem

When running cargo inside a sandbox that rejects access to ~/.cargo/credentials, cargo build fails. I prefer to run VScode in a sandbox and not give it access to confidential files such as ~/.cargo/credentials. cargo build really shouldn't need access to my credentials, so this seems like it should be avoidable.

Steps

  1. Change permissions such that ~/.cargo/credentials is unreadable
  2. Do some cargo action that does not require credentials
  3. You get: error: Permission denied (os error 13)

The error message is quite bad as it doesn't even say which file is affected! I had to use strace to determine that (which was hard because strace is blocked in the sandbox...)

EDIT: Error message fixed via #7649.

Possible Solution(s)

Only read credentials when needed, i.e., in cargo publish.

Notes

Output of cargo version:

cargo 1.41.0-nightly (8280633db 2019-11-11)
@RalfJung RalfJung added the C-bug Category: bug label Nov 23, 2019
@RalfJung RalfJung changed the title Cargo fails if ~/.cargo/credentials is unreadable cargo build fails when ~/.cargo/credentials is unreadable Nov 23, 2019
@est31
Copy link
Member

est31 commented Nov 24, 2019

The error message is quite bad as it doesn't even say which file is affected

Unfortunately, the Display impl of std errors doesn't output the file name but this opaque error msg. Not sure if there is an upstream discussion about it.

@ehuss ehuss added the A-configuration Area: cargo config files and env vars label Dec 3, 2019
bors added a commit that referenced this issue Jan 15, 2020
Load credentials only when needed

Credentials are always loaded, even if these are not used. If
access to confidential files such as credentials is not given,
`cargo build` fails despite not using credentials.

Fixes #7624.
@bors bors closed this as completed in 4b70f14 Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-configuration Area: cargo config files and env vars C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants