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.07k stars 193 forks source link

fix: Melos hangs on every command #691

Closed matthew-carroll closed 3 months ago

matthew-carroll commented 3 months ago

Is there an existing issue for this?

Version

3.0.1 (or maybe 5.3.0)

Description

Every time I run any melos command (globally activated), I get output like the following:

Resolving dependencies in /Users/matt/Projects/static_shock... 
Downloading packages... 
Got dependencies in /Users/matt/Projects/static_shock.
Building package executable... 
Built melos:melos.

Then Melos hangs for 5-10 seconds. Then Melos executes the command.

This long hang even occurred when I simply ran melos --version.

I'm not even sure what version I'm using because melos reports version 3.0.1, but I've run dart pub global deactivate melos and dart pub global activate melos multiple times. The dart tool tells me Activated melos 5.3.0.

Steps to reproduce

Run any melos command.

Expected behavior

Command execution should happen rapidly.

Screenshots

No response

Additional context and comments

Running on Mac OS - Sonoma 14.3.1

spydon commented 3 months ago

Which version do you have in the root pubspec of the project where you are running Melos?

matthew-carroll commented 3 months ago

That version is 3.0.1 - though I assume that was put there automatically when I created the project?

spydon commented 3 months ago

Upgrade that to 5.3.0 and it won't have to resolve an old version. Although it is strange that it should take time to resolve the old version on every command, it should be cached.

matthew-carroll commented 3 months ago

Should that version be getting auto-updated by melos? If not, are melos users supposed to change that number whenever they update the global tool?

spydon commented 3 months ago

Should that version be getting auto-updated by melos?

No

If not, are melos users supposed to change that number whenever they update the global tool?

Not necessarily, it is supposed to work so that we can do breaking changes in Melos without forcing the users to migrate all their projects at the same time. If you have specified for example melos: ^5.0.0, you'll use any versions between >=5.0.0 - <6.0.0, so you would be using the version you have installed until there is a breaking change and 6.0.0 is released.

matthew-carroll commented 3 months ago

But my version by 2 major versions behind...should there have been some message telling me I needed to change the number of 5.x?

spydon commented 3 months ago

But my version by 2 major versions behind...should there have been some message telling me I needed to change the number of 5.x?

That might be a good idea, but for now it's like any other dependency, that it is up to the maintainer to do. You could use renovate or dependabot to automatically update it for example.

matthew-carroll commented 3 months ago

Ok, I'm still rather confused about what that number in the root level pubspec means, but by changing that number of the delay is gone, so I'll close the issue.

spydon commented 3 months ago

Ok, I'm still rather confused about what that number in the root level pubspec means, but by changing that number of the delay is gone, so I'll close the issue.

It specifies which versions of Melos that you accept in the workspace. Compare it to if you would have for example riverpod: ^2.0.0 in there, this is pretty much the same thing. The melos binary that you have installed on the system makes sure that you run a melos version that is within your specified version range.