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

Only gitignore the top level target directory for 'cargo new' #3423

Closed
wants to merge 1 commit into from
Closed

Only gitignore the top level target directory for 'cargo new' #3423

wants to merge 1 commit into from

Conversation

dylanmckay
Copy link

This modifies the default .gitignore for new projects to ignore only the target folder in the crate root.

Without this, you cannot have a target/mod.rs module.

This will also mean that projects with crate dependencies in the same repository will have their target directories recognised by version control. In these cases, the projects should be using workspaces.

This modifies the default `.gitignore` for new projects to ignore only the `target` folder in the crate root.

Without this, you cannot have a `target/mod.rs` module.

This will also mean that projects with crate dependencies in the same repository will have their `target` directories recognised by version control. In these cases, the projects should be using workspaces.
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@steveklabnik
Copy link
Member

Without this, you cannot have a target/mod.rs module.

Is there a good reason for this? seems like an anti-pattern.

@dylanmckay
Copy link
Author

seems like an anti-pattern.

How do you figure?

@steveklabnik
Copy link
Member

in general, target is a directory that's for generated files, not source. Source files should be in src, tests, examples, and the like. I'd expect that rm -rf target would be the rough equivalent to cargo clean; you can't even make use of a target/mod.rs without special configuration.

@jonas-schievink
Copy link
Contributor

this is about things like src/target/mod.rs

@alexcrichton
Copy link
Member

Thanks for the PR! This has been proposed before, however, and closed due to this making the multi-crate experience work not-as-great by default.

The template is of course just that, a template, and can always be modified to suit an application's needs. I don't think there's going to be a one-size-fits-all here, unfortunately.

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

Successfully merging this pull request may close these issues.

6 participants