invertase / melos

🌋 A tool for managing Dart projects with multiple packages. With IntelliJ and Vscode IDE support. Supports automated versioning, changelogs & publishing via Conventional Commits.
https://melos.invertase.dev/~melos-latest
Apache License 2.0
1.08k stars 193 forks source link

fix: git dependency overrides which resolve in multiple packages #637

Closed XavierChanth closed 3 months ago

XavierChanth commented 6 months ago

Is there an existing issue for this?

Version

4.0.0

Description

Melos throws a fit when bootstrapping with a git dependency override in CI: See this GitHub actions workflow run

For some context, we have the packages at_client (dart), and at_client_mobile (flutter) which depends on at_client. We have this git dependency override in place for both packages:

dependency_overrides:
  at_chops:
    git:
      url: https://github.com/atsign-foundation/at_libraries
      path: packages/at_chops
      ref: pass_optional_key_params

This will fail, since by default melos will try to git clone to the same directory in parallel:

Resolving dependencies...
Git error. Command: `git clone --mirror https://github.com/atsign-foundation/at_libraries /opt/hostedtoolcache/flutter/stable-3.16.8-x64/.pub-cache/git/cache/at_libraries-ed225b56f65e31be444cc0aa4c9ba1b9ae3eb239`
stdout: 
stderr: fatal: destination path '/opt/hostedtoolcache/flutter/stable-3.16.8-x64/.pub-cache/git/cache/at_libraries-ed225b56f65e31be444cc0aa4c9ba1b9ae3eb239' already exists and is not an empty directory.
exit code: 128
BootstrapException: Failed to install.: at_functional_test at /home/runner/work/at_client_sdk/at_client_sdk/tests/at_functional_test.
Error: Process completed with exit code 1.

The solution is to disable runPubGetInParallel in melos.yaml:

command:
  bootstrap:
    runPubGetInParallel: false

Steps to reproduce

See description above.

Expected behavior

It would be nice if melos checks for git dependency overrides, or any git dependency conflicts between packages, and automatically falls back to running pub get serially. In addition, it would be nice if melos printed a hint to try disabling runPubGetInParallel when this error occurs.

Screenshots

No response

Additional context and comments

In our normal development workflows this isn't usually an issue. We only use git dependency overrides when we want to test against upstream package changes, I would like the speed of running pub get in parallel when possible.

spydon commented 6 months ago

Does this work when it's not in a CI environment?

spydon commented 4 months ago

@XavierChanth?

XavierChanth commented 4 months ago

Does this work when it's not in a CI environment?

We've not run into the conflict since. If I recall the problem correctly, the conflict was between a package and it's example creating a race condition by trying to clone the same repo to the same place at the same time. We've since resolved the issue through other means.

If you would like to investigate this issue further, see https://github.com/atsign-foundation/at_client_sdk/pull/1216, the commits are all open source. The race condition should still be possible, unless it's already been inherently fixed in melos.