-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo publish
ignores Cargo.lock in workspace
#11148
Comments
Modified the #[cargo_test]
fn in_workspace() {
Package::new("serde", "0.2.0").publish();
Package::new("serde", "0.2.1").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[project]
name = "foo"
version = "0.0.1"
authors = []
license = "MIT"
description = "foo"
[dependencies]
serde = "0.2"
[workspace]
members = ["bar"]
"#,
)
.file("src/main.rs", "fn main() {}")
.file(
"bar/Cargo.toml",
r#"
[project]
name = "bar"
version = "0.0.1"
authors = []
license = "MIT"
description = "bar"
workspace = ".."
[dependencies]
serde = "0.2"
"#,
)
.file("bar/src/main.rs", "fn main() {}")
.build();
p.cargo("generate-lockfile").run();
p.cargo("update -p serde:0.2.1 --precise 0.2.0").run();
p.cargo("package --workspace")
.with_stderr(
"\
[WARNING] manifest has no documentation, [..]
See [..]
[PACKAGING] bar v0.0.1 ([CWD]/bar)
[UPDATING] `dummy-registry` index
[VERIFYING] bar v0.0.1 ([CWD]/bar)
[DOWNLOADING] crates ...
[DOWNLOADED] serde v0.2.1 ([..])
[COMPILING] serde v0.2.1
[COMPILING] bar v0.0.1 ([CWD][..])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[WARNING] manifest has no documentation, [..]
See [..]
[PACKAGING] foo v0.0.1 ([CWD])
[VERIFYING] foo v0.0.1 ([CWD])
[DOWNLOADING] crates ...
[DOWNLOADED] serde v0.2.0 ([..])
[COMPILING] serde v0.2.0
[COMPILING] foo v0.0.1 ([CWD][..])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
)
.run();
let package_path = p.root().join("target/package/foo-0.0.1.crate");
assert!(package_path.is_file());
let f = File::open(&package_path).unwrap();
validate_crate_contents(
f,
"foo-0.0.1.crate",
&["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
&[],
);
let package_path = p.root().join("target/package/bar-0.0.1.crate");
assert!(package_path.is_file());
let f = File::open(&package_path).unwrap();
validate_crate_contents(
f,
"bar-0.0.1.crate",
&["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
&[],
);
} Note the different versions of serde that are being downloaded / compiled as part of the verify step in |
|
So as for fixes, on the surface, it seems simplest if we just track the root for the package that the ephemeral workspace is created for. No idea what all that would break and what it would take to make it all work. I wonder if we should refactor things to ask the workspace where the lockfile is instead of manually constructing it from the workspace root. |
Hm, yea, this isn't working as intended for a workspace. I'm not sure how this got overlooked. There is a test I think one option is to call |
Hi! I'm interested in working on this. @ehuss I tried replacing @rustbot claim |
I think starting with |
Thanks to all involved in resolving this issue, especially @kylematsuda for the implementation! |
It seems like this was fixed a long time ago, but when I tried to publish a library in workspace I got an error saying the build script modifies the source directory,
So, either the fix doesn't work for build scripts, or I need to do something about this that I don't know about. If it's the second, please help. EDIT:
|
You might be looking for #13447 which is tracking lockfiles for published libs. However, those seem like standard operations for library build scripts and yet we don't generally hear reports of problems so something else might be going on. |
Problem
Using
cargo publish
orcargo package
on a binary crate inside a workspace ignores theCargo.lock
in the workspace directory, whereascargo build
considers it. However, when movingCargo.lock
inside the binary crate root, all commands consider it.I believe that this means that crates published from workspaces, even when installed with
cargo install --locked
, do not respect the workspace'sCargo.lock
. This seems to contradict the Cargo book:Steps
To set up the environment:
Now run:
(Using
cargo publish
with--locked
does not change anything.)Possible Solution(s)
No response
Notes
I tried to gather some advice whether this is indeed a bug, but did not obtain any response so far.
Version
The text was updated successfully, but these errors were encountered: