Berry: [Bug] `yarn set version classic` fails with `Error: Invalid semver version`

Created on 3 Jan 2021  Â·  5Comments  Â·  Source: yarnpkg/berry

Describe the bug

nicolas@laptop:~/PROJECTS/CONCERTO/concerto$ yarn set version classic
➤ YN0000: Downloading https://nightly.yarnpkg.com/latest.js
➤ YN0001: Error: Invalid semver version
    at /home/nicolas/PROJECTS/CONCERTO/concerto/.yarn/releases/yarn-2.4.0.cjs:2:86456
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async a.mktempPromise (/home/nicolas/PROJECTS/CONCERTO/concerto/.yarn/releases/yarn-2.4.0.cjs:2:513898)
    at async Qe (/home/nicolas/PROJECTS/CONCERTO/concerto/.yarn/releases/yarn-2.4.0.cjs:2:86181)
    at async /home/nicolas/PROJECTS/CONCERTO/concerto/.yarn/releases/yarn-2.4.0.cjs:2:86042
    at async Function.start (/home/nicolas/PROJECTS/CONCERTO/concerto/.yarn/releases/yarn-2.4.0.cjs:2:388437)
    at async we.execute (/home/nicolas/PROJECTS/CONCERTO/concerto/.yarn/releases/yarn-2.4.0.cjs:2:85865)
    at async we.validateAndExecute (/home/nicolas/PROJECTS/CONCERTO/concerto/.yarn/releases/yarn-2.4.0.cjs:2:659490)
    at async Y.run (/home/nicolas/PROJECTS/CONCERTO/concerto/.yarn/releases/yarn-2.4.0.cjs:17:3854)
    at async Y.runExit (/home/nicolas/PROJECTS/CONCERTO/concerto/.yarn/releases/yarn-2.4.0.cjs:17:4021)
➤ YN0000: Failed with errors in 0s 386ms

To Reproduce


Reproduction

js repro yarn set version classic

bug

All 5 comments

This seems to be caused by the generation of the version here:

const formattedDate =
  date.getUTCFullYear() +
  leftPad(date.getUTCMonth() + 1) +
  leftPad(date.getUTCDate()) +
  '.' +
  leftPad(date.getUTCHours()) +
  leftPad(date.getUTCMinutes());

Is there any appetite for changing this so that it does not generate invalid semver? Perhaps using a - instead of a . before the time? Or prepending a non-zero before the hour? I don't know if there's a dependency on the current format.

In our case, this causes breakage to a Yarn v2 workflow that packs a GitHub dependency using Yarn Classic as part of the project installation.

Why not skipping hours and minutes and replace it with git ref :

yarn-1.23.0-20210102.git-123456.js

I've just opened https://github.com/yarnpkg/yarn/issues/8534 to address this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

milichev picture milichev  Â·  3Comments

janicduplessis picture janicduplessis  Â·  4Comments

larixer picture larixer  Â·  4Comments

juanpicado picture juanpicado  Â·  4Comments

IanVS picture IanVS  Â·  4Comments