When I cargo publish
from the package directory in my workspace, I get:
error: Source directory was modified by build.rs during cargo publish. Build scripts should not modify anything outside of OUT_DIR.
Added: {workspace_dir}/target/package/{package_name}-{version}/Cargo.lock
To proceed despite this, pass the `--no-verify` flag.
I’ve tried using cargo generate-lockfile
from the package directory, including with the --lockfile-path
, but it keeps generating a lockfile for the entire workspace. How do I generate the lockfile for just this one package?
I tried to run cargo package
and commit the lock file back into the package folder, but I get the same error. I confirmed that the file is the same, by checking that diff {package_name}/Cargo.lock target/package/{package_name}-{version}/Cargo.lock
is empty.
I would also accept a solution that stops generating the Cargo.lock
file, since this package is a library without a binary. Although I understand that Rust is moving toward always publishing Cargo.lock, so it’s slightly less preferred.
2