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
You can use the names or the pkgx display name e.g nodejs.org@20, however I recommend using the pkgx display name in yarns case, just to be specific of which type of yarn
I believe for other dependencies this problem probably does not occur because (if I remember correctly) if there are multiple versions of one package the version constraints are merged in some way. But because yarn 1.x and yarn >2 have different package names (classic.yarnpkg.com and yarnpkg.com), this merging does not happen.
If we add this it will definitely need to go into the docs that if pkgx.yml is defined then you'll need to explicitly define the pkgs needed in your project as the auto detect feature will be turned off as to not clash with the pkgx.yml dependencies
If you have both files you get both packages, since they have different names. I don't have good knowledge of all the yarn versions and I don't know what the reasoning for using two different packages names for yarn is and I don't know what the reasoning is to to choose yarn <2 for .yarnrc but yarn >=2 for yarn.lock.
But for .yarnrc the constraint could also be something like:
pkgs.push({ project: "yarnpkg.com", constraint: new semver.Range("<2") })
If I understand correctly this constraint would then be merged with others and resolve to a single package version.
Although that would only work if you move the versions from classic.yarnpkg.com into yarnpkg.com.
We can't merge the 2 as they are 2 different packages. This is something that has confused many yarn users... even me. And I'm not really sure about the .yarnrc preference for classic.yarnpkg.com. @jhheider do you have more context on this?
yes, in some cases, it will not be correct. the implicit assumption was that most yarn users will be using berry; however, it shouldn't likely not push both. if it has already pushed classic.yarnpkg.com it should not also add yarnpkg.com.
I'm also hitting this, and another solution is to let pkgx.yml define yarnpkg.com: 'none' or something similar. So there is an escape hatch for when pkgx picks up the wrong packages from the environment.
Activity
michaelessiet commentedon Dec 22, 2023
If you're not making use of a package you can remove it from the environment using e.g
env -yarnpkg.comLythenas commentedon Dec 22, 2023
Yes that works temporarily but there is no way to make it persistent for
dev, right?michaelessiet commentedon Dec 23, 2023
There is, create a
pkgx.yamlfile and define the dependencies there like soYou can use the names or the pkgx display name e.g
nodejs.org@20, however I recommend using the pkgx display name in yarns case, just to be specific of which type of yarnLythenas commentedon Dec 23, 2023
Yes, what I'm saying is that this only adds packages. The once that are auto-detected are still there and not removed.
If I remove the
yarn.lockso it does not pick up+yarnpkg.com. However that is part of the repo so deleting it is not really an option.Lythenas commentedon Dec 23, 2023
I believe for other dependencies this problem probably does not occur because (if I remember correctly) if there are multiple versions of one package the version constraints are merged in some way. But because yarn 1.x and yarn >2 have different package names (classic.yarnpkg.com and yarnpkg.com), this merging does not happen.
michaelessiet commentedon Dec 26, 2023
@mxcl Do we have something to handle this better already? Assigned from defining dependencies I haven't come across anything else
jhheider commentedon Dec 26, 2023
likely the solution is
if pkgx.yml.exists() skip_scanning_other_files().michaelessiet commentedon Dec 26, 2023
If we add this it will definitely need to go into the docs that if
pkgx.ymlis defined then you'll need to explicitly define the pkgs needed in your project as the auto detect feature will be turned off as to not clash with thepkgx.ymldependenciesLythenas commentedon Dec 26, 2023
I guess that would also be ok. Although maybe you want to autodetect and use additional packages from pkgx.yml.
I think the issue originates here:
https://github.com/pkgxdev/pkgx/blob/4787466a824d361fc9766073394378bb6b1c4811/src/utils/devenv.ts#L76-L82
If you have both files you get both packages, since they have different names. I don't have good knowledge of all the yarn versions and I don't know what the reasoning for using two different packages names for yarn is and I don't know what the reasoning is to to choose yarn <2 for .yarnrc but yarn >=2 for yarn.lock.
But for
.yarnrcthe constraint could also be something like:If I understand correctly this constraint would then be merged with others and resolve to a single package version.
Although that would only work if you move the versions from
classic.yarnpkg.comintoyarnpkg.com.michaelessiet commentedon Dec 27, 2023
We can't merge the 2 as they are 2 different packages. This is something that has confused many yarn users... even me. And I'm not really sure about the
.yarnrcpreference forclassic.yarnpkg.com. @jhheider do you have more context on this?jhheider commentedon Dec 27, 2023
I believe .yarnrc is specific to yarn1.
their migration guide lists
Convert your .npmrc and .yarnrc files into .yarnrc.yml. details.Lythenas commentedon Dec 27, 2023
But
yarn.lockis not specific to yarn>=2, right? So using fixedyarnpkg.comforyarn.lockis not correct, right?jhheider commentedon Dec 27, 2023
yes, in some cases, it will not be correct. the implicit assumption was that most
yarnusers will be using berry; however, it shouldn't likely not push both. if it has already pushedclassic.yarnpkg.comit should not also addyarnpkg.com.michaelessiet commentedon Jan 4, 2024
@jhheider has the issue of dev pushing
yarnpkg.comwhenclassic.yarnpkg.comis already installed been fixed?jhheider commentedon Jan 4, 2024
I don't believe I've seen a PR happen for that yet.
jakobvase commentedon Feb 2, 2024
I'm also hitting this, and another solution is to let pkgx.yml define
yarnpkg.com: 'none'or something similar. So there is an escape hatch for when pkgx picks up the wrong packages from the environment.