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.11k stars 198 forks source link

fix: `melos --version` shows wrong value #738

Closed feinstein closed 1 month ago

feinstein commented 1 month ago

Is there an existing issue for this?

Version

6.1.0 or 3.2.0

Description

When I run melos --version it shows:

3.2.0
There is a new version of melos available (6.1.0).

Then I try dart pub global deactivate melos and dart pub global activate melos and I get this:

....
+ typed_data 1.3.2
+ uri 1.0.0
+ web 1.0.0
+ yaml 3.1.2
+ yaml_edit 2.2.1
Building package executables...
Built melos:melos.
Installed executable melos.
Activated melos 6.1.0.

And then again if I run melos --version I get:

3.2.0
There is a new version of melos available (6.1.0).

Steps to reproduce

  1. melos --version 1.dart pub global deactivate melos 1.dart pub global activate melos
  2. melos --version

Expected behavior

melos --version should show 6.1.0

Screenshots

No response

Additional context and comments

Dart SDK version: 3.4.3 (stable) (Tue Jun 4 19:51:39 2024 +0000) on "macos_arm64"

spydon commented 1 month ago

You have specified the version that it is showing in your root pubspec, so this is not a bug.

feinstein commented 1 month ago

What do you mean by the version in my root pubspec.yaml? How can I know the version of the melos tool that I have installed in my system?

spydon commented 1 month ago

What do you mean by the version in my root pubspec.yaml? How can I know the version of the melos tool that I have installed in my system?

Run melos --version outside of a monorepo and you'll know the global version that is installed. Check your pubspec.yaml file in the root of the monorepo you currently are in and you'll see that it's an older version specified there.

feinstein commented 1 month ago

Oh I see, is this documented? Because when I run melos --help I only see the description of version for generating new versions of packages

spydon commented 1 month ago

It could probably be better documented indeed, both on the site and in the cli. Would you like to contribute with a PR with updated docs? :)

feinstein commented 1 month ago

I don't mind, but I don't know what is the expected behaviour, so I could document it

spydon commented 1 month ago

The expected behavior is the one that you have observed, --version reports the version of Melos that it is currently using, so if it is in a repo that constraints it to a lower version than what is installed globally that is the version that will be reported, and if you're not in a repo, or a repository that doesn't constrain the version, it will report the version installed globally.