I find it absolutely frustrating that Rust packaging/crates.io doesn't support namespaces. The arguments I've read are always theoretical/what ifs, but I've yet to be convinced the current situation is better than the practical benefits of namespaces.
TheCycoONE|5 years ago
In maven central, in my anecdotal experience, namespaces usually either distinguish forks of the same library, or to group related libraries. There has never been, in my experience, a case where I wanted two packages with the same name in different namespaces.
I think a better system of handling unmaintained crates; with the possibility of reclaiming a name would go a long way with the author's use case. I don't have any great ideas here: package with no update in some time (a year?) is eligible. Someone requests to take over name - the author is notified and has a period of time to click an "I'm still here" button. If they don't - new author gets the name. Some 'super version' number is incremented so crate authors opt into the new or old foo. That last part is where I'm the most hesitant.
stefan_|5 years ago
Reusing project names is just a straight no-go when that is what other peoples projects depend on. As soon as a package has a dependency, (name, version, source) need to be absolutely immutable.
mlindner|5 years ago
rkangel|5 years ago
It's a bit more consistent in that no-one gets good names, but is it really such a problem that a few people happened to get in early enough that they could call their library 'fuse'?
jmillikin|5 years ago
"rust-" or "-rs" is useless because it's on crates.io. "lib" or "-lib" similarly, unless it's part of a pair with a binary of the same name.
Here's a partial list of FUSE server implementations on crates.io:
Why do we make people come up with custom prefixes or opaque codenames when they could all be ~user/fuse ?atombender|5 years ago
A flat "top level" namespace encourages treating names, especially short names, as something with intrinsic value. You end up with the same problems that the .com namespace has, such as name squatting and first mover advantage.
Qualifying all names removes this property from names and levels the playing field. There's no value in "owning" github.com/somename/blah. Or, to take the NPM approach, @somename/blah.
ChrisSD|5 years ago
dthul|5 years ago
I don't think Rust itself needs to know about namespaces (as in: johndoe/fuse would still just expose a crate named "fuse". Crate name collisions can be handled with Cargo's already existing renaming ability.)
Yes, then the issue of namespace naming comes up. I guess that would be less of an issue than package-level collisions or squatting, but still, you don't want any random person to get the "google" namespace for example. Which could only be avoided by either manual review or something like DNS based verification (which has lots of drawbacks itself).
YorickPeterse|5 years ago
> How do we decide which person/entity gets a namespace?
You get a personal one, named after your user account. In addition, you can create up to N namespaces. After that, you either have to request more or pay a small fee. This prevents namespace squatting, while still giving you the option to register a few for specific projects.
> What if there's a dispute?
First come first serve seems pretty reasonable. Just because your company is named X doesn't mean you have a perpetual and exclusive right to use that name wherever you want.
> What do we do about all the currently un-namespaced crates?
You would have to leave them, and perhaps disallow un-namespaced crates after a certain point of time. Maybe take a look at how NPM handled thsi.
> How would Rust (the language) understand namespaces?
A crate `foo/bar`, with `foo` being the namespace, should just translate to something like `use foo::bar`.
majewsky|5 years ago
My proposal is to give everyone a namespace corresponding to their crates.io username, so if I want to publish a JSON library, it would be "user/majewsky/json".
Everything not prefixed with "user/" is a shared namespace which is handled by a team of curators. If someone wants to publish into the shared namespace, they need to apply for a package name. So if I think my JSON library should be the standard, I could apply for having it aliased to "json" or "encoding/json" or whatever. The curators would be allowed to impose an overall structure in the shared namespace to aid those who browse it.
Crucially, the curators should have the right to revoke an existing lease. If someone publishes their JSON library into the shared namespace as "json" and then later down the line abandons the project, other community members should be allowed to apply to take over that name. Of course, existing releases would stay untouched, but if I stopped maintaining my JSON library at 1.3.7, someone else should be allowed to take that over and publish 1.3.8 or later.
I would also impose the limitation that 0.x versions are not allowed in the shared namespace. If you want a nice package name, you should be ready to commit to at least a somewhat stable interface.
> How would Rust (the language) understand namespaces?
It's not hard to imagine a Rust that works with namespaced crates. What is hard is finding a solution that's backward- and forward-compatible.
ChrisSD|5 years ago
Any such RFC needs to take in to account previous discussions (and appreciate that the crates.io team is small). E.g.:
https://internals.rust-lang.org/t/crates-io-package-policies...
https://internals.rust-lang.org/t/namespacing-on-crates-io/8...
https://internals.rust-lang.org/t/pre-rfc-packages-as-namesp...
lmm|5 years ago
Do what maven does, and follow a reversed domain name convention. Or just first-come-first-served.
> What about namespace squatting?
It's much less of a problem, because having to use a different namespace is much less intrusive than having to use a different package name.
> What if there's a dispute?
What kind of dispute are you imagining? It's much harder for someone else's package name to cause a problem for you if packages are namespaced, since there's no way for someone else's package to end up in your namespace, whereas if you have to just use a convention like author-packagename then disputes are much more likely.
> What do we do about all the currently un-namespaced crates?
Either put them in a (deprecated) unnamed/root namespace, or turn each one into its own namespace (i.e. libfoo becomes libfoo:libfoo).
> How would Rust (the language) understand namespaces?
It doesn't need to, as far as rust is concerned a package is a package - they're handled at the cargo level.
> How would cargo work with them?
Dependencies would be (namespace, name, version) rather than just (name, version). And you just... do the sensible thing? This isn't a new idea, other languages have done this.
twic|5 years ago
twic|5 years ago
renewiltord|5 years ago
j88439h84|5 years ago
rat87|5 years ago
username_logger, username_fuse, etc.
?
A lot of the supposed benefits seem like downsides. The ability to have
bob_ward/docker and lilly_smith/docker seems like a misfeature
I guess you could argue it makes to avoid malicious packages w/ similar spelling but then they could just try the same thing with even less suspicion w/ similarly named namespaces
peacefulhat|5 years ago
jgraham|5 years ago
DougBTX|5 years ago
vaylian|5 years ago