0

The Cargo documentation for The dependencies table gives the following example:

# [PROJECT_DIR]/Cargo.toml
[workspace]
members = ["bar"]

[workspace.dependencies]
cc = "1.0.73"
rand = "0.8.5"
regex = { version = "1.6.0", default-features = false, features = ["std"] }
# [PROJECT_DIR]/bar/Cargo.toml
[package]
name = "bar"
version = "0.2.0"

[dependencies]
regex = { workspace = true, features = ["unicode"] }

[build-dependencies]
cc.workspace = true

[dev-dependencies]
rand.workspace = true

I am trying to implement using a dependencies table now for a project. I can't get the the rand.workspace = true syntax to work for me. I can only get the following syntax to work:

# [PROJECT_DIR]/Cargo.toml
[workspace]
members = ["bar"]

[workspace.dependencies]
cc = "1.0.73"
rand = "0.8.5"
regex = { version = "1.6.0", default-features = false, features = ["std"] }
# [PROJECT_DIR]/bar/Cargo.toml
[package]
name = "bar"
version = "0.2.0"

[dependencies]
regex = { workspace = true, features = ["unicode"] }

[build-dependencies]
cc = { workspace = true }

[dev-dependencies]
rand = { workspace = true }

Can anybody help?

Update

After @cafe25 confirmed this all works for them I checked and my program compiles with the syntax I was saying I couldn't get to work. I just get an error that appears related to VSCode:

Errors
async-graphql-poem.workspace: Error: Command failed: git --no-pager --git-dir="../.cargo/registry/index/github.com-1ecc6299db9ec823/.git" show origin/HEAD:as/yn/async-graphql-poem.workspace
fatal: path 'as/yn/async-graphql-poem.workspace' does not exist in 'origin/HEAD'

This appears to be an issue with the crates extension for VSCode.

  • 2
    What's the version of tools involved? Both versions work for me. – cafce25 Mar 23 '23 at 14:29
  • 1
    To answer your question, I'm using the latest Rust stable, `edition = "2021"`. But thanks so much for checking. I just checked and my program compiles using the syntax I was saying wasn't working. It's just what appears to be an extensions error in VSCode that was displaying as an error. I'm going to update my question. Thanks again. – suchapalaver Mar 23 '23 at 14:53

0 Answers0