Rust-Newbie - trying to install crates


#1

Forgive me all, but I’m new to rust and am trying to learn my way around.

I thought it best to download some crates to see some example code.

So I found cal - a small binary that works like a *nix cal command line utility.

So i typed cargo install cal - and I received an error when compiling it stating that

use std::time::duration::Duration; is incorrect because
module duration is private

Am I using cargo incorrectly? I assumed that when this person created cal v0.0.1 cargo would install dependency crates at the same version this person used when creating their crate. But it looks like since this person released this program, certain dependency and standard rust libraries have changed.


#2

You are not using Cargo incorrectly. cal was written before Rust 1.0, and a few things changed between when it was written and Rust 1.0, when the language and standard library was stabilized.

If you take a look at the cal repo, there is a fix that has been committed to make it compatible with Rust 1.0 and later, but it looks like that fix hasn’t been published to crates.io.

You should be able to check out that repo and compile it from there (git clone https://github.com/parkr/cal-rust.git), or pick a more up-to-date example to try out with cargo install. I recommend cargo install ripgrep, which installs an executable named rg for doing recursive grepping (like grep -r, ack or ag, but faster for most searches).

edit: Oh, you mention that you’re looking for something simple to look at, ripgrep is not particularly simple. If you were looking for something to try out cargo install with, it’s a useful tool that is nice to have around.


#3

Thanks for clarifying my issue. I will clone the latest from github and check out ripgrep. I’ve been using grep -r for so long I’ll have to teach my fingers to type rg!


#4

Cargo is able to install packages directly from git, like this: cargo install --git https://github.com/parkr/cal-rust


#5

Cool! I didn’t realize cargo could do this!