-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Cargo scripts try to build a nearby src/lib.rs if present #14476
Copy link
Copy link
Closed
Labels
A-cargo-targetsArea: selection and definition of targets (lib, bins, examples, tests, benches)Area: selection and definition of targets (lib, bins, examples, tests, benches)C-bugCategory: bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Z-scriptNightly: cargo scriptNightly: cargo script
Metadata
Metadata
Assignees
Labels
A-cargo-targetsArea: selection and definition of targets (lib, bins, examples, tests, benches)Area: selection and definition of targets (lib, bins, examples, tests, benches)C-bugCategory: bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Z-scriptNightly: cargo scriptNightly: cargo script
Type
Fields
Give feedbackNo fields configured for issues without a type.
Problem
If I place a script in the same directory as a crate, it uses crate's source files, but does not use crate's dependencies, causing unexpected compilation errors.
Steps
./Cargo.toml:./src/lib.rs:./script.rs:Running
./script.rscauses:This looks broken, because
src/lib.rsis compiled with scripts dependencies, not its usual crate dependencies.Possible Solution(s)
I would expect
Cargo.tomlandsrc/to be completely ignored by the scripts. Or if they're not ignored, to be compiled correctly as a library and included as an external crate in the script (liketests/ormain.rsget). But compiling the crate, but with a wrongCargo.tomlcontext seems like the worst of both.Notes
BTW, "warning:
package.editionis unspecified, defaulting to2021" is printed, even though I've tried to specify it in all places.Version