Lib.rs (was Crates.rs) β€” what's next?

I just tried adding the search engine to Firefox, but the resulting URL has a typo,
e.g. https://crates.res/search?q=libc

This site is a great resource. Thanks.
I think the title tag should be adjusted for the new name. Currently:
<title>Crates.rs β€” home for Rust crates // Lib.rs</title>

Found a somewhat strange fact, perhaps an unfinished change. The information about lazy_static crate states:

lazy-static.rs is available on crates.io.

But the link (as copied here - the same is on lib.rs) is pointing on crates.rs, not on crates.io, and therefore looks like broken, while in the repository (and on the crates.io itself) it is correct.

I just had another look. It's coming along pretty nice! congrats. There's two things that make crates.io handy for me, which are:

  • it's supported by ayu-rs, so I get a nice dark theme automatically
  • when I search for a specific crate name I always get notified clearly whether there is an exact match or not, which I use quite alot
  • I do use reverse deps, which I don't find on libs.rs. For me it's a hint of how many other people found that this crate served a purpose for them, and sometimes it can serve as "example code" on how to use the crate.

thanks for pursuing this

1 Like

@kornel Any reason why crates.rs should be called lib.rs? People are used to calling library in rust as crate as seen in crates.io.

1 Like

crates.rs was too similar to crates.io. I don't want them to be confusable.

I'm not attached to the "crate" term. The extern crate syntax is going away. There's Cargo.toml with a [package] section β€” without actually saying crate anywhere.

lib.rs is shorter, and nicely matches src/lib.rs.

11 Likes

I wonder if it would be nice to have a FAQ for lib.rs to avoid confusion with crates.io below on clicking Formely Crates.rs?

3 Likes

What's the update frequency of libs.rs? I'm planning to announce a crate I just published by linking to crates-io in the morning, but if libs.rs has it by that point, I'd probably slightly prefer linking it there.

Currently update runs hourly + there's some lag from caching by the CDN.

2 Likes

I see that lib.rs only seems to sort search results by "relevance". Personally, I don't like these sorta-opaque sorting criteria, and prefer to sort by a criterion that makes sense to me such as total crate downloads or recent crate downloads. These kind of sorting criteria are available today on crates.io's search, do you intend to eventually add them to lib.rs?

I've found crate-io's unfiltered download numbers to be noisy and in some cases leading to very misleading and IMHO unfair ordering of crates, so I don't plan to use them directly.

I wouldn't mind adding various "opaque" sorting criteria like popularity, trust, stability, etc. if there are strong use-cases for them. It's just that crate-io's download counter doesn't do what you'd expect.

2 Likes

The dark version renders pretty poorly on macOS using the system-wide Dark mode, in both Safari and Firefox:

6 Likes

Some user controlled curation would be nice. The first thing I look for when searching through any index is "how can I save myself from sifting through a thousand options". Sorting by a trending by date marker would be really good.

2 Likes

@kornel The cargo-n64 README doesn't appear on lib.rs, but it shows on https://crates.io/crates/cargo-n64

I'm not sure if it's a packaging issue, but the repo is structured with a cargo workspace, and the crate references the markdown file in the root directory: cargo-n64/Cargo.toml at 91a66648551448e371336f6258fe63b428e6d672 Β· rust-console/cargo-n64 Β· GitHub

I consider this a bug in Cargo. It creates packages that are missing files. Crates.io "cheats" by not reading the crate, but instead uploading and storing the readme separately at the time of publication, when it has full access to uploader's disk. I don't, so I can't get that readme from ../. I try to fudge it by searching git repo, but that doesn't always work.

Thanks for pointing me in the right direction. Just found the ticket you created a while ago: Relative paths in Cargo.toml readme Β· Issue #5911 Β· rust-lang/cargo Β· GitHub

Status update:

  • lib.rs now has more crates than crates.io! In addition to all crates-io crates, it also includes some handpicked projects that aren't on crates-io, e.g. rav1e, zola, citybound.

  • The site updates more often (10-15 minutes). I'm using stale-while-revalidate feature on the CDN, so even if some pages become out of date, they'll still load immediately, and refresh in the background.

  • The dark theme was an endless whack-a-mole, but it should be working now. Latest Safari (macOS and iOS) and Firefox support automatic theme switching to match the OS.

  • lib.rs/name URLs open crate pages and lib.rs?keyword searches!

  • I've added workarounds for many cases of broken data and READMEs missing from crate files.

  • Many have asked for a string to copy&paste to [dependencies], but I think that's a poor way of adding dependencies. cargo-edit is a much better solution, so I've added a fake-ish [Install] button to pages explaining the better way (plus that string to copy&paste if you really insist).

2 Likes
 LANG=C telnet lib.rs 443
Trying 104.18.52.16...
Connection failed: Connection refused
Trying 104.18.53.16...
Connection failed: Connection refused
Trying 2606:4700:30::6812:3410...
Connection failed: Network is unreachable
Trying 2606:4700:30::6812:3510...
telnet: Unable to connect to remote host: Network is unreachable
LANG=C telnet crates.io 443
Trying 52.200.184.208...
Connected to crates.io.
Escape character is '^]'.
1 Like

I would personally argue that this is a lib.rs security feature
Anybody getting dependencies, or even dependency metadata (like download URL and checksum) via unprotected connections, is opening themselves up to Man-in-the-Middle code injections.
There are documented cases from "upside-down-ternet" to NSA "quantum insert". Of course China has also demonstrated traffic injection with their "Great Cannon".

What part of your use-case is not covered by (https supporting) curl lib.rs?keyword, or wget lib.rs/cratename? I'm genuinely curious!

1 Like

I think @Dushistov is just using telnet to demonstrate the inability to connect, not that they'd actually expect lib.rs to offer telnet service. :smile:

8 Likes