alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
289 stars 51 forks source link

Unclear warning: Possible tilde intended instead of caret for a 0.x version. #1646

Open mgrojo opened 8 months ago

mgrojo commented 8 months ago

Checklist

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Add this dependency to a crate: ada_toml = "~0.3.0"
  2. Run alr build. ada_toml 0.3.0 is selected.
  3. Change dependency to: `ada_toml = "^0.3.0"``
  4. Run alr build
  5. This warning is displayed:
    ⭧ ada_toml 0.4.0 (upgraded from 0.3.0)
    warn: Possible tilde intended instead of caret for a 0.x version.
    Alire does not change the meaning of caret and tilde for pre/post-1.0 versions.
    The suspicious dependency is: ada_toml^0.3.0
    You can disable this warning by setting the option warning.caret to false.

Expected Behavior Why does it say that the meaning is not changed, when it is indeed changing the selected version, when only ~ is replaced by ^.

Maybe there is a reason for this warning, but I cannot see it from this case. Besides, what "pre/post" means in pre/post-1.0 versions? Should it say pre-1.0 since it refers to a 0.x version?

alr version Paste here the output of alr version.

APPLICATION
alr version:               2.0
libalire version:          2.0
compilation date:          2024-03-13 13:56:21
compiled with version:     10.5.0

CONFIGURATION
settings folder:           /home/mgr/.config/alire
cache folder:              /home/mgr/.local/share/alire
vault folder:              /home/mgr/.local/share/alire/releases
build folder:              /home/mgr/.local/share/alire/builds
temp folder:               /run/user/1000
force flag:                FALSE
non-interactive flag:      FALSE
community index branch:    stable-1.3.0
compatible index versions: ^1.1 & <=1.3.0
indexes folder:            /home/mgr/.config/alire/indexes
indexes metadata:          OK
index #1:                  (community) git+https://github.com/alire-project/alire-index#stable-1.2.1
toolchain folder:          /home/mgr/.local/share/alire/toolchains
toolchain assistant:       disabled
tool #1 gnat:              gnat_external=12.3.0
tool #2 gprbuild:          gprbuild=18.0.0
system package manager:    /usr/bin/apt
distro detection disabled: FALSE

WORKSPACE
root status:               VALID
root release:              issue=0.1.0-dev
root load error:           none
root folder:               /home/mgr/src/alire/issue
current folder:            /home/mgr/src/alire/issue

SYSTEM
distribution:              UBUNTU
host-arch:                 X86_64
os:                        LINUX
target:                    NATIVE
toolchain:                 SYSTEM
word-size:                 BITS_64
mosteo commented 8 months ago

The thing is, for versions before 1.0, there's an unwritten assumption that compatibility is maintained within a 0.x version, that is, the minor acts as major and the patch as minor. But this is not imposed by the semver spec, just a convention.

In some semver implementations, ^ means within the same major version, i.e., 1.x, except for 0.x versions, where it means within the same minor version, i.e, 0.1.x.

Our library doesn't change interpretation in 0.x and 1.x versions, i.e., ^0 is any 0.x and ^1 is any 1.x.

So, if you want to use pre-stable versions, but with a modicum of back-compatibility, you are supposed to stay within the same 0.x version. Which in some libraries is ^0.x and in others (like ours) is ~0.x.

Why does it say that the meaning is not changed, when it is indeed changing the selected version, when only ~ is replaced by ^.

It means that ~ always operates the same, be it a 0.x or a 1.x version: same .x. Same for ^.

Maybe there is a reason for this warning, but I cannot see it from this case.

The reason is to make clear that ^0.x won't give you stability within the pre-1 versions, as you can get updates, just as you saw, from e.g. 0.3 to 0.4.

Besides, what "pre/post" means in pre/post-1.0 versions? Should it say pre-1.0 since it refers to a 0.x version?

It refers to the first 1.0 version of a library, which is considered the first stable release. Yes, pre/post-1.0 was meant to be pre-1.0/post-1.0.

I'm open to a better wording. Perhaps rather than trying to explain on the spot, we can point to an alr help <topic> that goes in detail.

mgrojo commented 8 months ago

Thanks, it's clear now after the explanations.

The thing is, for versions before 1.0, there's an unwritten assumption that compatibility is maintained within a 0.x version, that is, the minor acts as major and the patch as minor. But this is not imposed by the semver spec, just a convention.

In some semver implementations, ^ means within the same major version, i.e., 1.x, except for 0.x versions, where it means within the same minor version, i.e, 0.1.x.

Without knowing those two facts about the semver spec and what other implementations are doing is impossible to understand the warning.

Why does it say that the meaning is not changed, when it is indeed changing the selected version, when only ~ is replaced by ^.

It means that ~ always operates the same, be it a 0.x or a 1.x version: same .x. Same for ^.

That's what you expect unless you know about other implementations, so I understood the warning as if it were mostly the opposite, that, in Alire, both caret and tilde for 0.x releases had the same meaning.

The result I wanted, was in fact what I got.

Besides, what "pre/post" means in pre/post-1.0 versions? Should it say pre-1.0 since it refers to a 0.x version?

It refers to the first 1.0 version of a library, which is considered the first stable release. Yes, pre/post-1.0 was meant to be pre-1.0/post-1.0.

I'm open to a better wording. Perhaps rather than trying to explain on the spot, we can point to an alr help <topic> that goes in detail.

I don't have a suggestion that could be still brief and understandable without the context, so I guess pointing to a topic or to the documentation in the web page would certainly help. In any case, someone looking for the meaning of this error should be able now to reach this explanation.

Thanks.