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

Support for package resolving from different origins #4118

Open
cpfeiffer opened this issue Jan 18, 2024 · 4 comments
Open

Support for package resolving from different origins #4118

cpfeiffer opened this issue Jan 18, 2024 · 4 comments
Labels
type-enhancement A request for a change that isn't a bug

Comments

@cpfeiffer
Copy link

I would like to be able to allow getting the same package from different origins. But the "hosted" URL of a package dependency appears to be part of the "package identity". Here it is explained that this is not supported atm:

However, conflicts can easily arise if your dependencies require a package with the same name from different repositories. For example, if package retry requires meta from pub.dev, and example_package requires meta from https://dart-packages.example.com. Therefore, if mirroring any packages into a private package repository it’s often necessary to mirror all dependencies and either update the dependencies section of each package, or override the default package repository.

IMHO it would be desirable to separate origin from identity. Imagine publishing packages with interdependencies for two years to your private registry, and then, for some reason, the host name/domain name changes. All these packages would become unusable, AFAIU. Or if you want to make them available to a customer -- you currently cannot provide the same packages through a different host.

As a package consumer, I would like to specify, or at least be able to override, where dependencies are fetched from.

FWIW, this is also how some other dependency managers work, e.g. maven, ivy, gradle, etc.

@sigurdm
Copy link
Contributor

sigurdm commented Jan 19, 2024

The package identity seen from the point of dart is only the package name. The question is I guess when a package A depends on another hosted package B, should B by default be from pub.dev or by default from the same host as A is hosted on (in pub it is from pub.dev (or actually PUB_HOSTED_URL by default)).

We have previously discussed allowing "mirroring urls" (such that fetching packages from hostA instead of hostB.

Another solution would be to have a way of saying "from the same host"...

or at least be able to override,

We have dependency_overrides. That can override where each package is fetched from.

@sigurdm sigurdm added the type-enhancement A request for a change that isn't a bug label Jan 19, 2024
@cpfeiffer
Copy link
Author

In e.g. Maven-land, it doesn't matter at all, from which repository an artifact is downloaded from, as long as the coordinates (GAV, groupId, artifactId, version) match. But still, you can run into a similar problem -- if a pom.xml declares a repository with a URL, and that URL is not accessible, the build will fail.

A discussion about this topic is here. The problems pointed out about a single settings.xml per user, where all repositories shall be managed, becomes moot as soon as you use one settings.xml per project instead, which is also what the newest Maven versions are suggesting (project/.mvn/settings.xml).

So to sum up, IMHO it would be desirable to

  • let dart packages declare hosted repositories ✔️
  • let consumers override declared hosted repositories
  • optionally let consumers specify the repositories to use entirely, ignoring any declared hosted repositories

such that package compatibility does not depend on the repository hostname anymore.

dependecy_overrides only help a little, because one would have to redeclare all transitive dependencies, which is what one wants the package manager to do.

@sigurdm
Copy link
Contributor

sigurdm commented Jan 22, 2024

Related to: #2226

@sigurdm
Copy link
Contributor

sigurdm commented Jan 22, 2024

Related to #2993

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants