Skip to content

fix: bootstrap race condition causes dart example to be restored before its pubspec_overrides.yaml is written #796

@ahmednfwela

Description

@ahmednfwela

Is there an existing issue for this?

  • I have searched the existing issues.

Version

6.2.0

Description

Running melos bootstrap with repos that contain dart packages with examples can sometimes fail because of race conditions, where flutter will try to resolve the example project before melos has a chance to write its pubspec_overrides.yaml

e.g. when running melos bootstrap in a clean clone of the oidc package, you can see oidc_web_core/pubspec_overrides.yaml present, but oidc_web_core/examples/pubspec_overrides.yaml is not generated yet.

image

this causes the following exception:

melos bootstrap
  └> D:\packages\oidc

Running "flutter pub get" in workspace packages...
  ✓ oidc
    └> packages/oidc
  ✓ oidc_example
    └> packages/oidc/example
  ✓ oidc_android
    └> packages/oidc_android
  ✓ oidc_example_android
    └> packages/oidc_android/example
  ✓ oidc_core
    └> packages/oidc_core
  ✓ oidc_default_store
    └> packages/oidc_default_store
  ✓ oidc_desktop
    └> packages/oidc_desktop
  ✓ oidc_flutter_appauth
    └> packages/oidc_flutter_appauth
  ✓ oidc_ios
    └> packages/oidc_ios
  ✓ oidc_linux
    └> packages/oidc_linux
  ✓ oidc_loopback_listener
    └> packages/oidc_loopback_listener
  ✓ oidc_macos
    └> packages/oidc_macos
  ✓ oidc_platform_interface
    └> packages/oidc_platform_interface
  ✓ oidc_web
    └> packages/oidc_web
  ✓ oidc_example_web
    └> packages/oidc_web/example
  - oidc_web_core
    └> packages/oidc_web_core
       └> Failed to install.

Resolving dependencies...
Downloading packages...
# other deps commented for brevity ...
! oidc_core 0.8.0 from path ..\oidc_core (overridden in .\pubspec_overrides.yaml)
Changed 65 dependencies!
6 packages have newer versions incompatible with dependency constraints.
Try `dart pub outdated` for more information.
# this is the problematic line, where flutter tries to execute pub get on the example before melos is able to create its overrides ...
Resolving dependencies in `.\example`...
Because oidc_web_core_example depends on oidc_core ^0.8.0 which doesn't match any versions, version solving failed.
BootstrapException: Failed to install.: oidc_web_core at d:\packages\oidc\packages\oidc_web_core.

Steps to reproduce

  1. git clone https://github.com/Bdaya-Dev/oidc && cd oidc
  2. git clean -xdf to make sure all caches are removed
  3. melos bs

Expected behavior

Melos should first create pubspec_overrides.yaml for all packages, then execute pub get on them in arbitrary order

Screenshots

No response

Additional context and comments

I tried running melos bootstrap --no-example, and the first problem was resolved, but then I am facing a different error:

d:\packages\oidc\packages\oidc\example\.dart_tool\package_config.json does not exist.
Did you run this command from the same directory as your pubspec.yaml file?
BootstrapException: Failed to install.: oidc at d:\packages\oidc\packages\oidc.

the only workaround I have found to solve this is to run the following commands in this specific order:

melos bs
melos bs --no-example

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingkeep openkeep PRs/issue open for further investigation before accepting.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions