We should investigate whether crates.io has restrictions on the length of crate names, as long names would yield in long file names which would be disallowed on some file systems.
It looks like it doesn't, the only name validation I see in krate.rs is ensure_name_not_reserved.
Two relevant name checking functions:
From IRC:
I鈥檓 speaking conceptually here. It is plausible that a crate with length of >128 will break pretty much on any filesystem
but there are also filesystems like fatsomeethingsomething which in some configurations can support 8.3 only
and there are also filesystems where one can plain configure limit of filename length
so it is a very plausible case of making cargo unusable for some people with some crate that has a longer filename
I鈥檓 pretty sure encryption uses some number of bytes in the filename to store some sort of metadata, reducing the path lenght even further
at least the linux implementation does
Hmm seems the crate name length maxes out at ~50~ EDIT: 44. Just is it enforced in crates.io or in cargo? It should be enforced on crates.io, as otherwise you could use the api directly in an abusive manner.
(source: find ~/.cargo/registry/index/github.com-1ecc6299db9ec823/ -type d -name .git -prune -o -type f -exec basename {} \; | awk '{print length}' | sort -n | uniq -c)
@frewsxcv yes, looks like valid_name is where it should be added, and I missed it because its called by the implementation of Decode for CrateName instead of Crate::create_or_update.
@est31 Can't find where it would be checked in crates.io, seems like it must be a cargo limit right now.
https://en.wikipedia.org/wiki/Comparison_of_file_systems Here鈥檚 a table of filesystems with their filename length limits.
Distribution of crate name lengths on crates.io: http://paste.ubuntu.com/24488671/
EDIT: sorry there was a mistake (it scanned the .git dir), had to update the command to exclude it.
The crate with the longest name is google-gamesconfiguration1_configuration-cli.
Let's just cap the length of all crates arbitrarily. I'd pick the longest crate name we have today, add 10, and then cap it at that. If there's problems someone will report an issue! (or find a shorter name)
I'd pick the longest crate name we have today, add 10, and then cap it at that.
That would be a limit of 54 then. That sounds okay for me.
Make it 64 and all programmers will be satisfied.
Most helpful comment
Make it 64 and all programmers will be satisfied.