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.19k stars 206 forks source link

Bootstrap hangs if dependency cannot be found #135

Closed dnys1 closed 2 years ago

dnys1 commented 3 years ago

The bootstrap command will hang on pub get when one of the packages cannot be found (e.g. if the name was misspelled, like pedantc instead of pedantic). This is actually quite easy to do while having dart.runPubGetOnPubspecChanges set to false in VSCode.

The issue is that pub get will keep retrying so the command never completes with an exit code, which _runPubGetForPackage expects. It took me a while to figure out why this was happening because there was no output to the console. One solution could be to pipe stderr for these commands to the console, instead of waiting until the command completes, which would alert the developer that something is wrong.

richard457 commented 2 years ago

This happens randomly on packages, even when nothing is miss-spelled or no dependency at all Take an example for this

name: flutter_datetime_picker
publish_to: "none"
description: A date time picker for flutter, you can choose date / time / date&time in English Dutch and Chinese, and you can also custom your own picker content
version: 1.5.1

environment:
  sdk: ">=2.12.0 <3.0.0"
  flutter: ">=1.17.0"

dependencies:
  flutter:
    sdk: flutter

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:

For the first time it bootstrapped then after adding more packages this started to hang.

richard457 commented 2 years ago

A good example to reproduce this is to clone the flutterfire repo on a new machine and do melos bootstrap, it will hang and does not report anything.

richard457 commented 2 years ago

I second @dnys1 to have some sort of console output so we can know how to troubleshoot. @Salakar

spydon commented 2 years ago

This happens randomly on packages, even when nothing is miss-spelled or no dependency at all

We are experiencing this too, it's very strange. Anything I can do to help troubleshoot this?

EDIT: Our issue was actually the same as the original poster's issue, it failed silently due to a git error:

Git error. Command: git fetch stdout: stderr: fatal: remote error: The unauthenticated git protocol on port 9418 is no longer supported. Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information. exit code: 128

A bit unrelated, but if anyone else runs into this when having git dependencies, just change to https.

nmccready commented 2 years ago

There needs to be way more logging indicating what package is currently being worked on and . Is there more than just melos bootstrap --verbose ??

blaugold commented 2 years ago

How about we let bootstrapping of a package fail if pub get does not finish after a timeout of 30 seconds? After the timeout, the collected output of pub would be printed as part of the error message.

Update: This issue in the pub has more background on what is going on. dart pub get does fail immediately when a dependency is misspelled. flutter pub get has its own additional infinite retry loop, which was implemented for a reason, and it's probably not a good idea to negate it.

We want to avoid spamming the console with the output from all concurrently running pub get invocations. An alternative would be to only start printing the output of pub get after some amount of time, e.g. 30s.