rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.23k stars 12.7k forks source link

Cargo.toml path [lib] cannot specify a folder? #96247

Closed Jzow closed 2 years ago

Jzow commented 2 years ago

Here is my Cargo.toml profile

[package]
name = "rustlibrary"
version = "0.2.0"
authors = [
    "James Zow <jameszow@163.com>"
]
license = "Apache-2.0"
repository = "https://github.com/Jzow/rustlibrary"
#documentation = "https://docs.rs/rustlibrary"
readme = "README.md"
description = "Integrate all rust related projects and books for easy reading"
edition = "2021"

[workspace]
members = [
    # other module
    "leetcode",
    "microsoft",
    # basics workspace
    "basics/attributes",
    "basics/conversion",
    "basics/crates",
    "basics/customtypes",
    "basics/expressions",
    "basics/flowofcontrol",
    "basics/formatprint",
    "basics/function",
    "basics/modules",
    "basics/primitives",
    "basics/types",
    "basics/utiltest",
    "basics/varbindings",
    # complex workspace
    "complex/closure",
    "complex/concurrent",
    "complex/generics",
    "complex/ownership",
    "complex/smartpointer",
    # example workspace
    "example/guessgame",
    "example/httpie",
    "example/journal",
    "example/queryer",
    "example/restaurant",
    "example/thumbor",
    "example/minigrep",
    # web workspace
    "web/webapp",
    "web/webservice",
    "web/cindy",
]

[lib]
# https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options
name = "rustlibrary"
path = "basics/crates"
bench = false

error message:

➜  rustlibrary git:(dev) ✗ cargo build
   Compiling rustlibrary v0.2.0 (/Users/jameszow/Documents/RustWorkSpace/rustlibrary)
error: couldn't read basics/crates: Is a directory (os error 21)

error: could not compile `rustlibrary` due to previous error

He can only specify ib.rs I want to build these sub modules, What should I do

Jzow commented 2 years ago

Should I go to the cargo to deal with this problem? I can't find the information of this configuration in the official document

ehuss commented 2 years ago

It is not really clear to me what you are trying to accomplish. The lib.path setting specifies the source file for the library (default is src/lib.rs). The path setting is documented here.