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

Crate names unable to have digits #8829

Closed
b-ncMN opened this issue Nov 3, 2020 · 4 comments · Fixed by #9098
Closed

Crate names unable to have digits #8829

b-ncMN opened this issue Nov 3, 2020 · 4 comments · Fixed by #9098
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-new

Comments

@b-ncMN
Copy link

b-ncMN commented Nov 3, 2020

Describe the problem you are trying to solve
Today, we had a project for uni, we could use any programming language to solve the problem and I wanted to use Rust as the language to solve the problem, unfortunately, in the specifications, we were told we needed the compiled binary that needed to be named "101Pong". So I tried creating a crate with that name, and cargo didn't let me do it.

Describe the solution you'd like
I'd like to see an option that can let one force the name of the crate even tho it is not authorized to have a crate with digits in front of the name, (I will not upload that crate to anywhere except a private GitHub repository), this would be great so that person doesn't have to use an external tool (like make/Makefile) to invoke the compilation process and then rename the binary from an authorized name to a non-authorized name

Notes

@b-ncMN b-ncMN added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Nov 3, 2020
@ehuss
Copy link
Contributor

ehuss commented Nov 3, 2020

You can change the name of the binary in Cargo.toml by setting the name field:

[[bin]]
name = "101Pong"

The associated filename would default to src/bin/101Pong.rs or you can explicitly set the filename like path = "src/main.rs".

I think it is unlikely we would change it to allow package names to start with numbers due to the problems that could cause, but I think it would be good to add this tip to the cargo new error message.

You can learn more about Cargo targets and default filenames at https://doc.rust-lang.org/cargo/reference/cargo-targets.html.

@b-ncMN
Copy link
Author

b-ncMN commented Nov 3, 2020

Okay, thanks for the tip, I wanted to be able to name my directory and crate the same name the exercise was but I guess I won't be able to

@ehuss ehuss added A-diagnostics Area: Error and warning messages generated by Cargo itself. Command-new labels Nov 30, 2020
@joao-conde
Copy link

@ehuss is this supposed to be an open issue? or is the OP request not meant to be possible at all?

@ehuss
Copy link
Contributor

ehuss commented Jan 24, 2021

@joao-conde This issue is open to track updating the error message. I have posted #9098 to close this.

@bors bors closed this as completed in 414ccb5 Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-new
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants