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

Fix deeply nested registries #676

Merged
merged 2 commits into from
Aug 4, 2024

Conversation

szlend
Copy link
Contributor

@szlend szlend commented Aug 3, 2024

Motivation

This allows building packages with crates from custom registries that reference other custom registries.

It works by scanning packages from Cargo.lock and adding any missing registries to crane's generated .cargo/config.toml. This matches Cargo's behavior where the top level project doesn't necessarily have to explicitly define all transitive registries.

Fixes #456

Checklist

  • added tests to verify new behavior
  • added an example template or updated an existing one
  • updated docs/API.md (or general documentation) with changes
  • updated CHANGELOG.md

@szlend
Copy link
Contributor Author

szlend commented Aug 3, 2024

Not sure what the best way would be to add a regression test. We already rely on alexandria for alt-registry tests, but we'd need another registry. In my reproduction example (https://github.com/szlend/crane-reg-test) I simply forked the alexandria index to have a second copy of the registry.

@szlend szlend marked this pull request as ready for review August 3, 2024 12:47
Copy link
Owner

@ipetkov ipetkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for fixing this @szlend ! This solution looks great, the cargo docs on source replacement do not cover this at all but using the registry url in place of [source.${name}] is definitely the correct thing to do because this is exactly what cargo vendor does. I also confirmed that this does fix the build for https://github.com/szlend/crane-reg-test (after adding in pkg-config and openssl to the inputs that is).

Not sure what the best way would be to add a regression test. We already rely on alexandria for alt-registry tests, but we'd need another registry. In my reproduction example (https://github.com/szlend/crane-reg-test) I simply forked the alexandria index to have a second copy of the registry.

I do think your reproduction is a great addition to have, but happy to do the same under my own name so you aren't on the hook for not breaking the test suite ;)

@ipetkov
Copy link
Owner

ipetkov commented Aug 4, 2024

Is there anything you had to do to get cargo to mix and match the registries in the Cargo.lock file or did you manually edit one in to reproduce the issue?

@ipetkov
Copy link
Owner

ipetkov commented Aug 4, 2024

Oh I see you published an actual crate to the upstream index

@ipetkov
Copy link
Owner

ipetkov commented Aug 4, 2024

Not sure the best way to proceed tbh, seems like we'd need to push more versions of crane test crates to the alexandrie index to untangle but I'm not 100% sure if we want to have to rely on them that way. Perhaps at some point it may be worth looking into standing up a https://kellnr.io instance just for our own testing (maybe even an ephemeral one in a NixOS VM test?), but I definitely don't want to block on that. Happy to merge this as in and fix the issue and we can circle back if we ever have a regression

@ipetkov ipetkov enabled auto-merge (squash) August 4, 2024 22:01
@ipetkov ipetkov merged commit c873fd2 into ipetkov:master Aug 4, 2024
18 checks passed
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.

Recursive registry vendoring doesn't work
2 participants