Paths override - .cargo/config.toml

Hi,
I was testing the paths override in the config as it is relevant to my scenario.
I did as was described Overriding Dependencies
But it doesnt seem to be working.
What I tried:
a - Cargo.toml

[package]
name = "a"
version = "0.1.0"
edition = "2021"

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

[lib]
crate-type = ["staticlib", "rlib"]

[dependencies]

b - Cargo.toml

[package]
name = "b"
version = "0.1.0"
edition = "2021"

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

[dependencies]
a = { path = "../a" }

It compiled.
I moved the 'a' to another folder under abcd
so now I have the following structure

  • b

    • Cargo.toml
    • .cargo
      • config.toml
  • abcd

    • a
      --Cargo.toml

b/.cargo/config.toml

paths = ["../abcd/a"]

This doesnt compile, cargo keeps looking for '../a'. I thought the path would get overridden by what's specified in .cargo/config.toml

user@mc:~/blah/b$ cargo build --verbose
error: failed to get `a` as a dependency of package `b v0.1.0 (/home/blah/b)`

Caused by:
  failed to load source for dependency `a`

Caused by:
  Unable to update /home/blah/a

Caused by:
  failed to read `/home/blah/a/Cargo.toml`

Caused by:
  No such file or directory (os error 2)

As you can see it's still trying to get to '../a'

What am I doing wrong here, or have I understood this incorrectly?

Thanks,
Amol

instead move 'a' to 'abcd', you need copy it to 'abcd',

├── a
├── abcd
│   └── a
└── b

and it will work

Hi,
Thanks for your reply.
I tried what you suggested and it did work, I'm not sure what this means though.
I thought paths override meant we are telling rustc to not look at the path in dependencies, just dont go there, go to the override instead.

Thanks,
A

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.