Lib.rs (Crates.rs)
Lib.rs is a fast, lightweight index of Rust libraries and applications.
Crates published to crates.io will automatically show up on lib.rs. Lib.rs is not a registry on its own, and it's not affiliated with crates.io or the Rust project.
Building
-
Install Rust, Node.js (Node is used for Sass styles), and Docutils (for
.rst
readmes).- Rust 1.48 or later
-
Clone this repository recursively, so that all subprojects are included:
git clone --recursive https://gitlab.com/crates.rs/crates.rs cd crates.rs
-
Run
make
. It will download, compile and run everything. In case it doesn't work, try the step-by-step instructions below.
Contributing
The site is open source. It aims to be friendly and will enforce Code of Conduct to Rust's high standards. Rust beginners are welcome. Contributions beyond just code, such as UX and design, are appreciated.
If you'd like to help improve it:
-
See the list of open issues or file an issue/bug report/question.
-
If you'd like to discuss the site or brainstorm solutions with a wider audience, Rust user forum is a good place. You can DM kornel, too.
Where to find the code?
- If you want to change look'n'feel (CSS): see the
style
subproject. - If you want to change HTML of the templates: see the
front_end
dir. - If you want to show new kind of data on the pages:
- Fetch/compute that data in one of the subprojects most relevant for that type of data (e.g. there's a subproject for interacting with GitHub API if you want to get information from there).
- Expose that data source in the
kitchen_sink
dir which connects all data sources together. - Put that data in the page helper objects (e.g.
CratePage
) in thefront_end
dir. - Use the data in HTML templates.
Building step-by-step
-
Get the initial data files for the site (about 200MB).
-
Extract the data files in
.xz
format using 7zip, The Unarchiver (Mac) orunxz data/*.xz
.- Put them all (
crate_data.db
,cratesio.rmpz
, etc.) in thedata/
subdirectory of crates.rs checkout.
- Put them all (
-
Generate front-end styles:
cd style npm install npm run build
-
Start a local server (open it in a new terminal or run in the background):
cd ../server cargo run
-
Serve the HTML and the styles together:
cd ../style npm start
This will launch a local web server on localhost:3000 that serves HTML from
front_end/public/
and live reload styles fromstyle/src/*.scss
, so you can browse the site and edit the styles locally.Note that opening of the homepage for the first time takes a long time, because it may need to fetch and cache thousands of crates.
Troubleshooting
- If you get "patch for … in … did not resolve to any crates." error when building, delete
Cargo.lock
files from the project. - If you get "deadline elapsed" error pages, just refresh. Cache takes time.
- Search won't work until you run
reindex_crates --all
from thereindex
subproject.