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

can't "cargo clean" after running "cargo test" (permission denied) #6943

Closed
matthiaskrgr opened this issue May 14, 2019 · 8 comments · Fixed by #6947
Closed

can't "cargo clean" after running "cargo test" (permission denied) #6943

matthiaskrgr opened this issue May 14, 2019 · 8 comments · Fixed by #6947
Labels
C-bug Category: bug

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented May 14, 2019

cargo 1.36.0-nightly (759b6161a 2019-05-06)
release: 1.36.0
commit-hash: 759b6161a328db1d4863139e90875308ecd25a75
commit-date: 2019-05-06

repro:

git clone https://github.com/rust-lang/cargo
cd cargo
git checkout 414c1eb4d5142716ca461a2814ad9e3d4bdbeca6
cargo test --release
cargo clean 

cargo clean fails with:

error: could not remove build directory

Caused by:
  failed to remove file `/home/matthias/vcs/github/cargo/target/cit/t1183/home/.cargo/config`

Caused by:
  Permission denied (os error 13)
@matthiaskrgr matthiaskrgr added the C-bug Category: bug label May 14, 2019
@matthiaskrgr
Copy link
Member Author

I can't even rm -rf target o.O

rm: cannot remove 'target/cit/t1183/home/.cargo/config': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/credentials': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/.package-cache': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/objects/info': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/objects/pack/pack-0b90bbf1f43cc1666839974020faf8a4ff52665d.idx': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/objects/pack/pack-0b90bbf1f43cc1666839974020faf8a4ff52665d.pack': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/refs/heads': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/refs/tags': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/refs/remotes/origin/master': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/hooks/README.sample': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/info/exclude': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/description': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/config': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/HEAD': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/logs/refs/remotes/origin/master': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.git/FETCH_HEAD': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.last-updated': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/index/-76cbec63376b1d8f/.cache/3/f/foo': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/cache/-76cbec63376b1d8f/foo-0.1.0.crate': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/src/-76cbec63376b1d8f/foo-0.1.0/.cargo-ok': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/src/-76cbec63376b1d8f/foo-0.1.0/Cargo.toml': Permission denied
rm: cannot remove 'target/cit/t1183/home/.cargo/registry/src/-76cbec63376b1d8f/foo-0.1.0/src/lib.rs': Permission denied

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented May 14, 2019

Looks like this was caused by 414c1eb / #6940

@matthiaskrgr
Copy link
Member Author

I'll see if I can iron out a fix.

matthiaskrgr added a commit to matthiaskrgr/cargo that referenced this issue May 15, 2019
bors added a commit that referenced this issue May 15, 2019
tests: registry: revert readonly permission after running tests.

Fixes #6943
@carnoxen
Copy link

rust-lang/vscode-rust#630
It's not yet solved.

@muhammad-osaid-tekfocal
Copy link

muhammad-osaid-tekfocal commented Feb 5, 2021

rust-lang/vscode-rust#630
It's not yet solved.

@bors Please reopen this issue. I am on
Windows 10
Rust (rustc 1.49.0 (e1884a8e3 2020-12-29))
VSCode ( 1.53.0 )

Cannot perform a simple cargo clean.

`PS D:\my_app> cargo clean
error: could not remove build directory

Caused by:
failed to remove file D:\my_app\target\rls\debug\deps\libaho_corasick-f8f60bbcd8d855dc.rmeta

Caused by:
Access is denied. (os error 5)`

@Eh2406
Copy link
Contributor

Eh2406 commented Feb 5, 2021

Is the test still running?

@muhammad-osaid-tekfocal
Copy link

muhammad-osaid-tekfocal commented Feb 5, 2021

Is the test still running?

@Eh2406
Which test? I am just running a hello world console app.

@Eh2406
Copy link
Contributor

Eh2406 commented Feb 5, 2021

Sorry for the confusion I read the title too quickly. The common version of this problem that I run into is that I run cargo test in one terminal/editor then do cargo clean. The cleaning fails as (on windows at least) you can't delete a file that is currently being run, and my tests are still running. It can also happen when I am using a program while working on it. Or if Rust-analyzer is using files while I am trying to clean them.

If your issue is "can't clean a file while a running program is using it" then I don't think there is anything cargo can do to fix that. It is a limitation of the operating system. If your case is different, as the OPs was here, then please open a new issue with a clear reproducible example. If you are not sure, then there are places to get help diagnosing like users.rust-lang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants