Skip to content

cargo new --template ignores/replaces/overwrites .gitignore #3859

Closed
@ssokolow

Description

@ssokolow

While investigating another flaw in --template, I discovered the following undesired behaviour when generating a test project from my boilerplate for CLI utilities:

diff -u -ur ../rust-cli-boilerplate/.gitignore ./.gitignore
--- ../rust-cli-boilerplate/.gitignore  2017-03-09 13:33:13.345285768 -0500
+++ ./.gitignore        2017-03-23 11:41:35.619386304 -0400
@@ -1,2 +1,3 @@
-/callgrind.out.justfile
-/target
+target/
+**/*.rs.bk
+Cargo.lock

While I admit I forgot to exclude *.rs.bk, the rest is unhelpful.

What's worse is that I don't see how this actually helps anything, given that, for a project template, there isn't really much of a purpose to .gitignore outside of being passed on to the generated projects. (It's not as if the template's Cargo.toml is valid TOML before the placeholder for the author list gets substituted.)

You'll also notice that it's adding Cargo.lock to the .gitignore when this is specifically intended as --bin project template, not a --lib one, so that's not helpful either.

I think a proper solution would be to only generate a .gitignore if none is present in the template

As-is, I'm forced to go back to what I used before... a wrapper script.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions