Problem adding dependency to the mixed lib/bin crate

Hi all,
Compiler gives me an error when I'm trying to add dependency to one of my crates in the workspace.
I have following workspace structure:

test_combi/
  bin/app
    src/
      lib.rs
      main.rs
    Cargo.toml
      [package]
      name = "app"
      version = "0.1.0"
      edition = "2021"

      [lib]
      name = "startup"
      path = "src/lib.rs"

      [[bin]]
      name = "app"
      path = "src/main.rs"
  integration-tests/
    ...
    Cargo.toml
      ...
      [dependencies]
      startup = { path = "../bin/app" }
Cargo.toml
  [workspace]
  members = ["bin/app", "integration-tests"]

And when I try to build it I'm getting an error:

error: no matching package named `startup` found
location searched: .../test_combi/bin/app
required by package `integration-tests v0.1.0 (.../test_combi/integration-tests)`

Is this some special configuration that cargo doesn't support or I'm doing something wrong?

Thanks in advance.

The error message says "no matching package named startup found". Your package is named "app", not "startup".

[package]
name = "app"

So, either change the name to "startup" or change the dependency to

startup = { package = "app", path = "../bin/app" }

It's usually better to structure your project with fewer things being renamed, though, since that creates fewer surprises for readers.

1 Like

Thanks. It works now.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.