Publish on crates.io under different name

Suppose I have written a tool called foo. I'm going to call it foo. The name is non-negotiable (maybe I really love it or it has extensive internal use).

Now I want to publish it on crates.io so other Rust users can easily cargo install foo. But alas! Somebody already has published a crate there. It's long abandoned or maybe squatted so I'm not concerned about actual confusion between my foo and their foo, but it means I can't publish it.

Is there any way around this? Can I give my crate a "real name" and a "crates.io name"? Then I could call it foo-timmmm or something and cargo install foo-timmmm would give a foo binary.

Is this what you're looking for?

2 Likes

The name used on crates.io is the name of the package specified in Cargo.toml. The name of a library crate and of binary crates other than the default main.rs can be configured separately using the name field of the target configuration in Cargo.toml.

You could have your package name set to something unambiguous, while providing a binary target named whatever you want. That should require very few changes to your current setup.

1 Like

What you're looking for is answered above from others. And there are some real usecases in the wild.

  • rg, the well known grep written in Rust, is installed via cargo install ripgrep with package name ripgrep and binary name rg in the manifest.
[package]
name = "ripgrep"

[[bin]]
bench = false
path = "crates/core/main.rs"
name = "rg"
  • dust, du written in Rust, is installed via cargo install du-dust with
[package]
name = "du-dust"

[[bin]]
name = "dust"
path = "src/main.rs"

But it's fairly confusing for me as a user to see the binary name, package and repo name are different[1], since I have to remember multiple names for the same thing.


  1. Hmm, I just find dust is in du-dust package but in dust repo. :frowning: ↩ī¸Ž

4 Likes

Is this what you're looking for?

Well, not exactly. I mean it obviously helps in some situations but I was more thinking about things where you want the package to have a specific name (sorry I maybe wasn't 100% clear).

For example Facebook released a package called reindeer, how do they publish this on crates.io given that there is an existing package with the same name? They aren't going to rename the package.

I guess the answer is "they can't" and maybe "crates.io is primarily for libraries"? Just checking I hadn't missed anything. :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.