dub icon indicating copy to clipboard operation
dub copied to clipboard

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

Open ArthaTi opened this issue 1 year ago • 0 comments

System information

  • dub version: 1.32.0
  • OS Platform and distribution: ArchLinux 6.6.8-zen1-1-zen
  • compiler version v2.106.0

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

ArthaTi avatar Jan 24 '24 15:01 ArthaTi