Publish libraries with internal dependencies

I have a workspace with 2 libraries

➜  cargo-workspaces tree
├── Cargo.lock
├── Cargo.toml
├── lib-one
│   ├── Cargo.toml
│   └── src
│       └──
└── lib-two
    ├── Cargo.toml
    └── src

I have lib-one with "log" dependency and lib-two with dependency on "lib-one'.


name = "lib-one"
version = "0.1.0"
authors = ["Ivan Skiridomov <>"]
edition = "2018"

log = "0.4"


name = "lib-two"
version = "0.1.0"
authors = ["Ivan Skiridomov <>"]
edition = "2018"

lib-one = "^0.1"

I expect that when i run cargo publish from lib-one directory, it will be published. But it throw an error instead:

➜  lib-one git:(master) ✗ cargo publish 
    Updating index
error: no matching package named `lib-one` found
location searched: registry ``
required by package `lib-two v0.1.0 (/Users/i_skiridomov/Projects/tmp/cargo-workspaces/lib-two)

How i can publish workspace libraries with dependencies to crate registry ?

Answering myself: in lib-two/Cargo.toml should be a path attribute.

lib-one = {path = "../lib-one", version="^0.1", registry="local-registry"}

Is it correct way ?

Yep, you need both a path and a version.

For local development, cargo will use the path dependency. When publishing, however, Cargo will rewrite the dependency in Cargo.toml to mention only the version.

Unrelated, but in Cargo version = "^0.1" is equivalent to version = "0.1", that is, circumflex is optional.

1 Like

This question should be asked on the forum. This forum ( is dedicated to the development of Rust itself.