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

Error on cargo clean when target directory is a mount point #11887

Open
nandesu-utils opened this issue Mar 26, 2023 · 8 comments
Open

Error on cargo clean when target directory is a mount point #11887

nandesu-utils opened this issue Mar 26, 2023 · 8 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-clean S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@nandesu-utils
Copy link

Problem

I am using custom script to create a target and mount a tmpfs into it but when I run usual cargo clean it tries to delete the directory which fails with error due to busy resource since a mount point can't be deleted without unmounting first.

Proposed Solution

I think having a flag that controls whether the user would want to delete the /target directory when cleaning is going to help.

Notes

No response

@nandesu-utils nandesu-utils added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Mar 26, 2023
@epage
Copy link
Contributor

epage commented Mar 27, 2023

Would you be willing to look into how other build systems handle this problem?

@nandesu-utils
Copy link
Author

Would you be willing to look into how other build systems handle this problem?

What do you mean by that? What should I look for?

Some existing generic build systems for Rust are either badly supported or stalled, but what I need is merely this small flag just not to suppress error code and keep from using rm -r in scripts by using cargo clean instead, especially if the target directory has uncommon path specified.

If there is any problem or I just missed something, please point that out.

@epage
Copy link
Contributor

epage commented Mar 28, 2023

Would you be willing to look into how other build systems handle this problem?

What do you mean by that? What should I look for?

e.g. go clean

Its both useful to see what we can learn from problems that other build systems have. It also provides an idea of how prevalent the problem is.

@nandesu-utils
Copy link
Author

I do not understand what do you mean by that.

Clean command in go is not fully analogous to Cargo's command since there is basically no left over objects remaining in the source directory except for few specific ones; it uses temporary directory for intermediary files and source directory as a target for binary output. Same cmake uses an output target for removing objects on cleaning and I am not sure how it works, barely used cmake though.

About prevalent problems, there was fleet which handled many things by itself but... currently it's unavailable it seems? Considering other build system, say, D's DUB doesn't even remove the target binary as it only cleans the cached files.

I am not sure what kind of things can be learned from cleaning commands in build systems without changing the semantics of how cargo manages building crates. I just think this flag would be useful for small scripts (and so I made a PR and I already have used the custom fork with this PR to assist the building pipeline, and it simplified building; I didn't notice perf regressions too).

@nandesu-utils
Copy link
Author

It would be nice if Cargo itself would support using different means for target directory filesystem where build artifacts are located but that's a no-go:

  1. This is system-specific, or even environment-specific (sandboxed environments of any kind, mounting is ok on Linux but what about Windows?)
  2. This is already implemented in (some way) via build.target-dir which can be put into .cargo/config.toml or via an argument --config build.target-dir and do it manually depending on the environment.

I found that (2.) was just not as simple as some quick manual mount and forgetting about it until next reboot and just pressing arrow keys until I find cargo clean --keep-directory; it could be shortened to --keep-dir though.

So this is why I suggested such a flag; other build systems either use their own means for temporary files already in temporary folders or provide same or less features as Cargo does right now relative to this problem.

@weihanglo weihanglo added the S-needs-team-input Status: Needs input from team on whether/how to proceed. label Apr 26, 2023
@ehuss
Copy link
Contributor

ehuss commented May 2, 2023

A few questions and comments on this:

@ehuss ehuss added S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. and removed S-needs-team-input Status: Needs input from team on whether/how to proceed. labels May 2, 2023
@poliorcetics
Copy link
Contributor

As I understand the issue, rust-lang/rfcs#3371 would resolve this, I would appreciate comments on it if you think it doesn't @nandesu-utils :)

@epage epage changed the title Flag for keeping target directory on clean Error on cargo clean when target directory is a mount point Oct 24, 2023
@epage
Copy link
Contributor

epage commented Oct 24, 2023

I've updated the title to focus on the end-user problem, rather than one specific solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-clean S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests

5 participants