You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Why do Yarn "transparent" commands use hardcoded versions? #202
Current transparent commands and associated versions: npm init8.19.2 npx8.19.2 pnpm init7.12.2 pnpx7.12.2 pnpm dlx7.12.2 yarn dlx3.2.3
I would have guessed that e.g. updating yarn to 3.2.4 using corepack prepare yarn@3.2.4 --activate (or corepack prepare yarn@stable --activate) would result in yarn dlx using yarn3.2.4, so I was a bit surprised to hear that this is not the case.
I would have guessed that e.g. updating yarn to 3.2.4 using corepack prepare yarn@3.2.4 --activate (or corepack prepare yarn@stable --activate) would result in yarn dlx using yarn3.2.4, so I was a bit surprised to hear that this is not the case.
That sounds like a bug to me. Would you like to send a PR to fix that?
When isTransparentCommand (when running a transparent command), definition.transparent.default (when available) will be chosen over defaultVersion. In my local testing, this seems to be the source of the bug.
E.g. if: definition.transparent.default: 3.2.3+sha224.953c8233f7a92884eee2de69a1b92d1f2ec1655e66d08071ba9a02fa defaultVersion: 3.2.4
(3.2.3 was the Yarn transparent.default version for Corepack 0.14.2)
Running yarn dlx create-astro will result in yarn dlx using Yarn 3.2.3.
Now, running yarn dlx create-astro will result in yarn dlx using Yarn 3.2.4.
I'm a little confused about why this was written the way it was in #19 (what problems were being solved), I'm guessing defaultVersion will almost always be set, so after my proposed fix, definition.transparent.default will rarely be used.
Maybe the intended behavior was:
If user has changed the packageManager version via e.g. corepack prepare yarn@stable --activate, use that version.
Otherwise, use the transparent.default version, if set (which it is for Yarn).
Otherwise, use the default version.
Oh, and only yarn has a value for transparent.default, so presumably this change will only alter the behavior of yarn dlx -- if config.json is otherwise left as-is, yarn dlx will use 1.22.19 instead of 3.2.4.
What's the thinking behind defaulting to Yarn v1 (classic)? Given that Yarn v2 was released over 2.5 years ago, and Yarn v1 entered maintenance mode at the same time. Granted, from npm's perspective, yarn@latest is 1.22.19, so maybe it's for consistency with that? corepack prepare yarn@stable --activate takes you all the way from 1.22.19 to 3.2.4.
changed the title [-]Why do `transparent` commands use hardcoded versions?[/-][+]Why do Yarn "transparent" commands use hardcoded versions?[/+]on Feb 7, 2025
Activity
aduh95 commentedon Oct 29, 2022
That sounds like a bug to me. Would you like to send a PR to fix that?
merceyz commentedon Oct 29, 2022
Context for this issue: yarnpkg/berry#4850 (comment)
Indeed, ideally it should only do that if the version it would have used doesn't support
dlx.mrienstra commentedon Oct 29, 2022
Working on it!
mrienstra commentedon Oct 31, 2022
sources/main.ts#L57-L59:
When
isTransparentCommand(when running atransparentcommand),definition.transparent.default(when available) will be chosen overdefaultVersion. In my local testing, this seems to be the source of the bug.E.g. if:
definition.transparent.default:3.2.3+sha224.953c8233f7a92884eee2de69a1b92d1f2ec1655e66d08071ba9a02fadefaultVersion:3.2.4(
3.2.3was the Yarntransparent.defaultversion for Corepack0.14.2)Running
yarn dlx create-astrowill result inyarn dlxusing Yarn3.2.3.This code gives the desired result:
Now, running
yarn dlx create-astrowill result inyarn dlxusing Yarn3.2.4.I'm a little confused about why this was written the way it was in #19 (what problems were being solved), I'm guessing
defaultVersionwill almost always be set, so after my proposed fix,definition.transparent.defaultwill rarely be used.Maybe the intended behavior was:
packageManagerversion via e.g.corepack prepare yarn@stable --activate, use that version.transparent.defaultversion, if set (which it is for Yarn).defaultversion.Oh, and only
yarnhas a value fortransparent.default, so presumably this change will only alter the behavior ofyarn dlx-- ifconfig.jsonis otherwise left as-is,yarn dlxwill use1.22.19instead of3.2.4.What's the thinking behind defaulting to Yarn v1 (classic)? Given that Yarn v2 was released over 2.5 years ago, and Yarn v1 entered maintenance mode at the same time. Granted, from
npm's perspective,yarn@latestis1.22.19, so maybe it's for consistency with that?corepack prepare yarn@stable --activatetakes you all the way from1.22.19to3.2.4.[-]Why do `transparent` commands use hardcoded versions?[/-][+]Why do Yarn "transparent" commands use hardcoded versions?[/+]yarn initignores global default version #589 as a duplicate of this issue