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

Dependency override in pubspec.yaml ignored when pubspec_overrides.yaml exists #4387

Open
scopendo opened this issue Sep 12, 2024 · 3 comments
Labels
type-enhancement A request for a change that isn't a bug

Comments

@scopendo
Copy link

Environment

  • Dart version: 3.5.2
  • OS kind and version: macOS 14.6.1
  • Are you using the Chinese community mirror or a corporate firewall? No

Problem

We commonly use a pubspec_overrides.yaml file during development to set a relative path to internal packages (in different repositories) that our app depends on, leaving the pubspec.yaml set to a git URL to not break builds on our CI server. We don't commit pubspec_overrides.yaml.

Occasionally, we use the dependency_overrides section of the pubspec.yaml to force a later version of a third-party dependency, which is needed on our CI server. This override is ignored by dart pub get|upgrade unless it is repeated in the pubspec_overrides.yaml file. This is cumbersome and can be error-prone.

pubspec.yaml
name: example
description: Example App
publish_to: "none"
version: 1.0.0

environment:
  sdk: ">=3.0.0 <4.0.0"

dependencies:
  ...
  firebase_core: ^2.32.0

  flutter:
    sdk: flutter

  example_common:
    git:
      url: ssh://git@bitbucket.org/example/example-common.git
      ref: v1.0.0
   ...

dependency_overrides:
  # This override will be ignored if it's not specified in pubspec_overrides.yaml
  firebase_core: ^3.2.0
pubspec_overrides
dependency_overrides:
  example_common:
    path: ../example_common

  # The override of firebase_core in pubspec.yaml will be ignored unless also specified here
  firebase_core: ^3.2.0

Expected behavior

I expected that the dependency overrides in pubspec_overrides.yaml would complement overrides in pubspec.yaml.

Actual behavior

The dependency overrides in pubspec.yaml are ignored.

@sigurdm
Copy link
Contributor

sigurdm commented Sep 26, 2024

This is working as intended. (Otherwise you could not remove overrides with a pubspec_overrides.yaml file).

Maybe we could communicate better if there are overrides in both places.

@sigurdm sigurdm added the type-enhancement A request for a change that isn't a bug label Sep 26, 2024
@scopendo
Copy link
Author

scopendo commented Sep 26, 2024 via email

@sigurdm
Copy link
Contributor

sigurdm commented Sep 26, 2024

which could also be handled by setting the override accordingly.

Not sure I get how this would be done.
Say foo is overridden in pubspec.yaml. How would you create a pubspec_overrides.yaml that removes the override?

I vaguely remember us discussing this, and deciding this was the most useful and predictable behavior. It seems to me simpler that a field in pubspec_overrides replaces the same field in pubspec.yaml, not merging with it.

I can fully see how there are cases where you desire the merging behavior.

However I doubt that we are going to break this.

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