1

When I run a program that uses this in3-rs crate I get an error. I expect it to be installed because I followed the directions here: https://crates.io/crates/in3

I installed the Requirements described here: https://crates.io/crates/in3 I am using Ubuntu 18, cargo 1.49.0, and rustc 1.49.0. I tried to install in3, in3-rs, in3-sys, and async-std each separately (with a sudo cargo install ). Each time I got a message saying "error: specified package... has no binaries"

I ran this command: cargo install --list

I saw this:

ripgrep v12.1.1:

rg

I tried using a variety of different Cargo.toml files. But to install the ripgrep crate, I needed no Cargo.toml file.

I ran this command: sudo cargo install in3

But I saw this:

[sudo] password for jdoe: Updating crates.io index error: specified package in3 v0.1.7 has no binaries

A relevant version is returned in the output. My Ubuntu server has access to the internet. I have googled this problem, and I think that SO is where questions about Rust should be asked.

I tried the three suggestions for the content of the file for Cargo.toml that this link has.

When my Cargo.toml file had this stanza in3 = "0.1.7", the error was reproducible.

I had the same error when my Cargo.toml file had these two lines:

[dependencies]
in3 = "0.0.2"

The error was reproduced a third time when my Cargo.toml file had these three lines:

[dependencies]
async-std = "1.5.0"
in3 = "0.2.0"

To reproduce the problem, I ran "sudo cargo install in3"

I also tried to use sudo cargo install (without an argument to install) with the two Cargo.toml versions with the [dependencies] stanza. But I got this error on those attempts:

error: failed to parse manifest at /opt/in3-3.1.2/rust/Cargo.toml

Caused by: this virtual manifest specifies a [dependencies] section, which is not allowed

I tried using this as the Cargo.toml (and another version without the [dependencies] section):

[package]
name = "in3"
version = "0.2.0"
edition = '2018'

[dependencies]
async-std = "1.5.0"
in3 = "0.2.0"

I saw this:

Updating crates.io index error: specified package `in3 v0.1.7` has no binaries

Update: I used "sudo cargo build" with this as my Cargo.toml file:

[package]
name = "in3"
version = "0.1.7"
edition = "2018"

[[bin]]
name = "in3"
path = "/home/jdoe/rust/contint.rs"

[dependencies]
async-std = "1.5.0"
in3 = "0.1.7"

It worked. I then ran sudo cargo run, and it worked. But when I ran sudo cargo install in3, I got an error.

I ran this: cargo install --list

But in3 is still not installed. I ran a rust program, and it confirmed that in3 is not installed.

UPDATE (more recent): I ran rustc foobar.rs But I saw this:

error[E0433]: failed to resolve: maybe a missing crate in3? --> foobar.rs:4:5 | 4 | use in3::eth1::*; | ^^^ maybe a missing crate in3?

How do I install the in3 crate?

Ankwat
  • 21
  • 2
  • 5
    Does this answer your question? [Error installing a crate via cargo: specified package has no binaries](https://stackoverflow.com/questions/37706999/error-installing-a-crate-via-cargo-specified-package-has-no-binaries) Don't use `cargo install` to add dependencies, you simply need to add it to your `Cargo.toml`. Your link to the `in3` crate shows an example of how to do that. – kmdreko Jan 10 '21 at 04:23
  • No, unfortunately my problem happens with different Cargo.toml values. I updated my question to provide details of what happens. – Ankwat Jan 10 '21 at 19:21
  • If your `Cargo.toml` just has the `[dependencies]` section, then it is incomplete. You need a [`[package]`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-package-section) section with `name`, `version`, and `edition`. – kmdreko Jan 10 '21 at 22:04
  • I tried a Cargo.toml version with name, version and edition. It also failed with the same error. – Ankwat Jan 10 '21 at 22:32
  • 2
    As I said before, *don't use* `cargo install`. At this point you should just be able to use `cargo build` or `cargo run`. – kmdreko Jan 10 '21 at 23:19
  • I have made progress because of your comments. Unfortunately, I cannot install in3 still. The "cargo build" and "cargo run" worked when I fixed the .toml file. But in3 is still not installed. – Ankwat Jan 11 '21 at 03:35
  • Cargo libraries like `in3` aren't "installed". It won't show up in `cargo install --list`. If you were able to run `cargo build` with it listed as a dependency, then you can use it in your Rust code. What do you mean by "I ran a rust program, and it confirmed that in3 is not installed"? – kmdreko Jan 11 '21 at 03:50
  • I ran "rustc foobar.rs", and I saw the problem was that a statement referring to in3 caused a problem. This comment can be deleted to keep the comments from being excessive. – Ankwat Jan 11 '21 at 04:14

1 Answers1

0

I think you may have misunderstood package management with cargo. Since in3 is a library and not a binary crate, you cannot install it.

cargo install does not install dependencies like npm install or pip install does. cargo install will install binaries into your local filesystem (typically $HOME/.cargo/bin) for you to run.

Cargo will resolve dependencies for you when you cargo run/check/build. You do not need to install dependencies.

You may want to start a new folder structure and try the following:

  1. Run cargo init. This will create a new binary package
  2. Edit Cargo.toml and add the in3 dependency and version.
  3. Modify the main.rs file to use the in3 library.
  4. Run the program with cargo run. You will notice that cargo is resolving various dependencies while compiling your program.

For more info on Cargo, here is the getting started guide.

Rhuarc13
  • 135
  • 1
  • 9