Skip to content

Erased version specification for dependency, converted to "" instead of ">0.0.0" #2901

Closed

Description

@p0nce

System information

  • dub version: DUB version 1.35.1, built on Jan 6 2024
  • OS Platform and distribution: Windows 11
  • compiler version ldc2-1.36.0-windows-multilib

Bug Description

I'm using the numem package, who has an optional dependency on tinyd-rt
In its dub.sdl:

dependency "tinyd-rt" version=">0.0.0" optional=true

But on build: it says
image

Indeed the version specification is converted in the DUB own directory to this JSON:

image

The dependency has no more version specifier, it seems it got lost in the conversion.

How to reproduce?

Clone the yxml package and try to dub upgrade:
https://github.com/AuburnSounds/yxml

Expected Behavior

A pristine and preserved version specification.

Activity

  1. WebFreak001 commented on Apr 17, 2024

    @WebFreak001
    Member

    does it work if you change it to "*"?

    The error probably appears because >0.0.0 is not a valid format, you probably meant >=0.0.0 - however dub should show an issue for this.

    See https://dub.pm/dub-reference/dependencies/ for valid version syntaxes and what they mean.

  2. p0nce commented on Apr 18, 2024

    @p0nce
    ContributorAuthor

    It's not my package, and I think DUB should reject invalid version specifications.

  3. Geod24 commented on Jun 10, 2024

    @Geod24
    Member

    >0.0.0 is a valid format, although slightly useless: https://devhints.io/semver

    @WebFreak001 looks like your documentation is incomplete, it does not include >=1.0.0 <2.0.0 for example.

    dub/source/dub/dependency.d

    Lines 1037 to 1110 in a913071

    public static VersionRange fromString (string ves) @safe
    {
    static import std.string;
    enforce(ves.length > 0);
    if (ves == Dependency.ANY_IDENT) {
    // Any version is good.
    ves = ">=0.0.0";
    }
    if (ves.startsWith("~>")) {
    // Shortcut: "~>x.y.z" variant. Last non-zero number will indicate
    // the base for this so something like this: ">=x.y.z <x.(y+1).z"
    ves = ves[2..$];
    return VersionRange(
    Version(expandVersion(ves)), Version(bumpVersion(ves) ~ "-0"),
    true, false);
    }
    if (ves.startsWith("^")) {
    // Shortcut: "^x.y.z" variant. "Semver compatible" - no breaking changes.
    // if 0.x.y, ==0.x.y
    // if x.y.z, >=x.y.z <(x+1).0.0-0
    // ^x.y is equivalent to ^x.y.0.
    ves = ves[1..$].expandVersion;
    return VersionRange(
    Version(ves), Version(bumpIncompatibleVersion(ves) ~ "-0"),
    true, false);
    }
    if (ves[0] == Version.branchPrefix) {
    auto ver = Version(ves);
    return VersionRange(ver, ver, true, true);
    }
    if (std.string.indexOf("><=", ves[0]) == -1) {
    auto ver = Version(ves);
    return VersionRange(ver, ver, true, true);
    }
    auto cmpa = skipComp(ves);
    size_t idx2 = std.string.indexOf(ves, " ");
    if (idx2 == -1) {
    if (cmpa == "<=" || cmpa == "<")
    return VersionRange(Version.minRelease, Version(ves), true, (cmpa == "<="));
    if (cmpa == ">=" || cmpa == ">")
    return VersionRange(Version(ves), Version.maxRelease, (cmpa == ">="), true);
    // Converts "==" to ">=a&&<=a", which makes merging easier
    return VersionRange(Version(ves), Version(ves), true, true);
    }
    enforce(cmpa == ">" || cmpa == ">=",
    "First comparison operator expected to be either > or >=, not " ~ cmpa);
    assert(ves[idx2] == ' ');
    VersionRange ret;
    ret.m_versA = Version(ves[0..idx2]);
    ret.m_inclusiveA = cmpa == ">=";
    string v2 = ves[idx2+1..$];
    auto cmpb = skipComp(v2);
    enforce(cmpb == "<" || cmpb == "<=",
    "Second comparison operator expected to be either < or <=, not " ~ cmpb);
    ret.m_versB = Version(v2);
    ret.m_inclusiveB = cmpb == "<=";
    enforce(!ret.m_versA.isBranch && !ret.m_versB.isBranch,
    format("Cannot compare branches: %s", ves));
    enforce(ret.m_versA <= ret.m_versB,
    "First version must not be greater than the second one.");
    return ret;
    }

  4. s-ludwig commented on Jun 11, 2024

    @s-ludwig
    Member

    I wonder if Version.minRelease shouldn't be "0.0.0-0" instead of just "0.0.0", as that is really the lowest representable version. Also, the condition for determining whether to add a ">" part and a "<" part during the string conversion seems a little bit off and I'd say they should include a || !m_inclusiveA / || !m_inclusiveB addition respectively.

    Also, although is may be less likely to be a problem, Version.maxRelease ("99999.0.0") is completely arbitrary and doesn't seem like a meaningful constant.

  5. self-assigned this
    on Jun 11, 2024
  6. added 2 commits that reference this issue on Jun 11, 2024
    e4e0318
    290e3ce
  7. added a commit that references this issue on Jun 11, 2024
    95e2ba6
  8. p0nce commented on Jun 11, 2024

    @p0nce
    ContributorAuthor

    Thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions