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: bootstrap race condition causes dart example to be restored before its pubspec_overrides.yaml is written #796

Open
1 task done
ahmednfwela opened this issue Nov 24, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@ahmednfwela
Copy link

ahmednfwela commented Nov 24, 2024

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
@ahmednfwela ahmednfwela added the bug Something isn't working label Nov 24, 2024
@ahmednfwela ahmednfwela changed the title fix: bootstrap race condition causes flutter example to be restored before its pubspec_overrides.yaml is written fix: bootstrap race condition causes dart example to be restored before its pubspec_overrides.yaml is written Nov 24, 2024
ahmednfwela added a commit to Bdaya-Dev/oidc that referenced this issue Nov 24, 2024
@spydon
Copy link
Collaborator

spydon commented Nov 25, 2024

A workaround is to use path dependencies for the examples, since its not that important that it's not published anywhere (usually) explicit versions doesn't matter as much as for packages and apps.

@ahmednfwela
Copy link
Author

yes, but I think the root problem is that melos is writing pubspec_overrides.yaml and then running pub get immediately, the correct approach would be to write out all the yaml files and then the order of running pub get will not matter

@spydon
Copy link
Collaborator

spydon commented Nov 25, 2024

@ahmednfwela that could very well be, if you have time to investigate it further and provide a PR I can assign you to the issue?

@ahmednfwela
Copy link
Author

sure, that would be great @spydon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants