-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 Scaffold A New Project With Name Beginning With Number? #8613
Comments
I am not sure I understand this issue. In particular, here's the exact code that checks against this cargo/src/cargo/util/restricted_names.rs Lines 45 to 57 in ab32ee8
Or did I misunderstood you? |
@hbina "This is a reasonable restriction imo." To me is seems like a completely unnecessary restriction. Folder names beginning with numbers are perfectly valid, and in this case I do want to create a folder name that begins with a number (mostly because these folders represent chapters, and I want them to be ordered automatically by the file system). Can we remove this digit check altogether? I don't see what purpose or benefit it serves. |
This works if you want the folder to start with a number: Now, I'd be excited for a PR that improved the error message to something like:
I don't know how hard that would be. |
Thanks for the explanation @Eh2406 🙏 I agree that your proposed error message would be a nicer UX. |
I know that it's been a long time @JimLynchCodes. However maybe someone encounter this problem again so the solution is:
And you can simply change the directory's name:
And after that operation if you go to project dir:
You can simply run the project without any problems:
Important: You shouldn't change the [package]
name = "hello-world"
version = "0.1.0"
edition = "2021" |
@lofiguy Is your answer not unnecessary long and complex?
The above code will create a folder 1-hello-world with a crate with the name hello-world The code in the directory 1-hello-world can be run like any project using cargo run |
I am looking for the same thing, for the same reasons ;) |
Problem
Problem is that cargo gives an error "error: Package names starting with a digit cannot be used as a crate name" rather than creating a project with name beginning with number.
Steps
run this:
Possible Solution(s)
Notes
There is the additional output in the console, "use --name to override crate name", but I'm not really sure how to change my command to make it work. 🤔
Output of
cargo version
: cargo 1.42.0 (8633429 2020-01-31)The text was updated successfully, but these errors were encountered: