Can't use my_crate even though it's there and compiles

I have a cargo project that uses a library made by myself:

[dependencies]
liborwellprofile_protobuf_rust = {path = "./liborwellprofile/proto_rust"}

On this folder: ./liborwellprofile/proto_rust there's a functional Cargo.toml project that builds correctly.

On any file of my cargo project, I cannot do

use liborwellprofile_protobuf_rust;

It says that this crate does not exist.

Entire tree:

|-- Cargo.lock
|-- Cargo.toml
|-- build.rs
|-- liborwellprofile
|   |-- CMakeLists.txt
|   |-- OrwellProfile2.h
|   |-- SimpleUUID.cpp
|   |-- SimpleUUID.h
|   |-- Utilities.h
|   |-- architectures.proto
|   |-- decoder_preferences.proto
|   |-- devices.proto
|   |-- event_messenger_preferences.proto
|   |-- external_device.proto
|   |-- gen.sh
|   |-- openvpn.proto
|   |-- orwell_messages.proto
|   |-- orwell_profile.proto
|   |-- proto_cpp
|   |-- proto_dart
|   |-- proto_rust
|   |-- renderer_preferences.proto
|   |-- rtsp_preferences.proto
|   |-- stream.proto
|   |-- stream_setup.proto
|   |-- stream_setup_collection.proto
|   |-- utils.h
|   |-- uuid.proto
|   `-- vpn.proto
|-- src
|   |-- common //------- tried using liborwellprofile_protobuf_rust in files inside here
|   `-- main.rs //------- tried using liborwellprofile_protobuf_rust here
`-- target
    |-- debug
    `-- rls

Here's the proto_rust project:

.
|-- Cargo.lock
|-- Cargo.toml
|-- build.rs
|-- src
|   |-- main.rs
|   `-- protos
`-- target
    |-- debug
    `-- rls

Here's the Cargo.toml of the project I'm trying to use:

[package]
name = "liborwellprofile_protobuf_rust"
version = "0.1.0"
authors = ["Lucas Zanella <me@lucaszanella.com>"]
edition = "2018"
build   = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]

[dependencies]

[build-dependencies]
protobuf-codegen-pure = "2.3"

Did you import the crate in main.rs?

use extern crate CRATE_NAME;
use CRATE_NAME::path::to::file::*;

Also, if you have the error pointed by rustc, you can search it directly.
Its quite probable you'll find it. It seems to be common.

tried that but didn't work.

After that I noticed that the crate wasn't building. I don't know why I thought it was. Thanks!

1 Like