dlang / dub

Package and build management system for D
MIT License
673 stars 230 forks source link

`dub add` breaks `~>x.0` dependency specification #2830

Closed ArthaTi closed 3 months ago

ArthaTi commented 8 months ago

System information

Bug Description

DUB documentation specifies the two version specifications ~>a.b and ~>a.b.c, where the former accepts any minor and patch release since a.b.0, and the latter accepts any patch release since a.b.c. The documentation does not define any behavior for specification ~>a like ~>5.

DUB appears to incorrectly reformat any version specification following the ~>a.b format, if the minor version is specified to be 0, to the ~>a format. Since behavior of this format is undocumented, it is unclear how it is to be understood — would ~>5 also include version 6.0.0 or not?

How to reproduce?

Add a dependency and set the version specification. For example:

{
    "authors": [
        "artha"
    ],
    "dependencies": {
        "raylib-d": "~>5.0"
    },
    "description": "A minimal D application.",
    "license": "proprietary",
    "name": "dubtest"
}

Add any other dependency with dub add, for example dub add fluid. The package will be reformatted, and the previously added dependency, which in this example is raylib-d, will have the "dot zero" part removed.

Expected Behavior

The version specifier should stay as is, with minor version preserved. DUB should reject the major-only specification ~>a as invalid.

Logs

Using dub registry url 'https://code.dlang.org/'
Note: Failed to determine version of package dubtest at .. Assuming ~master.
  Version selection for dependency raylib-d (raylib-d) of dubtest is missing.
  Missing dependency raylib-d ~>5 of dubtest
             Adding dependency fluid >=0.6.0-alpha <0.7.0-0
Geod24 commented 3 months ago

This is not a bug, but should probably be changed regardless: https://github.com/dlang/dub/pull/2928