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

Allow dependency version overrides #620

Open
kszlim opened this issue Jan 6, 2024 · 3 comments
Open

Allow dependency version overrides #620

kszlim opened this issue Jan 6, 2024 · 3 comments
Labels
✨ enhancement Feature request

Comments

@kszlim
Copy link

kszlim commented Jan 6, 2024

Problem description

ie. package A depends on C ~=1.0, B depends on C ~=2, C has versions 1 and 2, but the subset depended on in A is actually semantically compatible with version 2, so it would work, just that the allowed version specifier for A is overly restrictive (and likely the developer hasn't tested with that config specifically)

Would be useful to be able to do something like:

[dependencies]
A = "*"
B = "*"

[dependencies.overrides]
C = 2

Then version constraints for depending on C would be ignored and we just use whatever is specified.

Not sure if this gets more complicated when including pypi-dependencies.

@geoHeil
Copy link

geoHeil commented Aug 14, 2024

See #1814

@ruben-arts as discussed on discord

@geoHeil
Copy link

geoHeil commented Aug 14, 2024

See also #1817

@alexkreidler
Copy link

I would like to propose nested overrides similar to how NPM does it. 1, 2, 3

For example, suppose surya depends on opencv-python and I want a different version. You can just add an overrides section to your package.json specify the sub-dependency you want to override:

{
  "overrides": {
    "opencv-python": "2.3.0"
  }
}

For more specific overrides, you can target nested dependencies:

{
  "overrides": {
    "parent-package": {
      "sub-dependency": "desired-version"
    }
  }
}

You can also override a specific version of a package:

{
  "overrides": {
    "parent-package@1.0.0": {
      "sub-dependency": "desired-version"
    }
  }
}

Finally you can use the full flexibility of NPM package references:

Git specifiers:

"overrides": {
  "some-package": "github:user/repo#branch-or-commit"
}

Replacing a package with another package entirely:

"overrides": {
  "old-package": "npm:new-package@1.0.0"
}

I've used this pattern many times for

  1. Patching dependencies with known security issues
  2. Replacing existing dependencies with forks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement Feature request
Projects
None yet
Development

No branches or pull requests

3 participants