Skip to content
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

Handle cargo workspaces in git repositories #3482

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Flamefire
Copy link
Contributor

@Flamefire Flamefire commented Oct 14, 2024

Crates downloaded from crates.io can just be put into the vendored-sources directory.
However a referenced git repository might contain multiple crates in a so-called "workspace".
If we put such a workspace into the vendor folder, cargo fails with

found a virtual manifest at [...]Cargo.toml instead of a package manifest

This solution uses a separate folder for sources downloaded from git repositories and checks them for workspaces.
If they are "regular", i.e. don't have a workspace, they are put to the vendored sources from crates.io.
Otherwise they are left in the git-vendor directory.

Additionally refine the config.toml entry for sources vendored from git. This allows to override a specific git URL and revision with the path to the extracted repository.
Otherwise we would need entries for each crate in workspaces but then cargo tries to verify the revision and fails with

Unable to update https://github.com/[...]?rev=[...]
Caused by: can't checkout from 'https://github.com/[...]': you are in the offline mode (--offline)

I also have a Stack Overflow question on that in case there is a better solution: https://stackoverflow.com/questions/79065892/how-to-patch-a-cargo-git-dependency-that-contains-a-workspace

Crates downloaded from crates.io can just be put into the
vendored-sources directory.
However a referenced git repository might contain multiple crates in a
so-called "workspace".
If we put such a workspace into the vendor folder, cargo fails with
> found a virtual manifest at [...]Cargo.toml instead of a package manifest

This solution uses a separate folder for sources downloaded from git
repositories and checks them for workspaces.
If they are "regular", i.e. don't have a workspace, they are put to the
vendored sources from crates.io.
Otherwise they are left in the git-vendor directory.

Additionally refine the config.toml entry for sources vendored from git.
This allows to override a specific git URL and revision with the path to
the extracted repository.
Otherwise we would need entries for each crate in workspaces but then
cargo tries to verify the revision and fails with
> Unable to update https://github.com/[...]?rev=[...]
> Caused by: can't checkout from 'https://github.com/[...]': you are in the offline mode (--offline)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant