-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] yarn set version berry
writes absolute (non-portable) path into .yarnrc.yml
#921
Comments
I came across the same issue. I tried to find where the issue was but was not successful. If someone could point me in the right direction I'd be glad to implement a fix. |
The first thing to figure out is whether the problem is truly the 2.x or rather the 1.x. The 2.x uses The 1.x, however, seems to use |
I can't check right now but I assume it's the 1.x because it happens when I
execute the command against a project without a .yarnrc, and I have yarn 1
globally installed.
…On Mon, Feb 10, 2020, 9:09 AM Maël Nison ***@***.***> wrote:
The first thing to figure out is whether the problem is truly the 2.x or
rather the 1.x. The 2.x uses path.relative
<https://github.com/yarnpkg/berry/blob/master/packages/plugin-essentials/sources/commands/set/version.ts#L207>
to reference the bundle, so I'm surprised it would end up absolute.
The 1.x, however, seems to use path.resolve
<https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/policies.js#L158>
which opens the door to an absolute path. If you want to lend a hand, I'd
be happy to review the fix on the 1.x repository to release it in a 1.22.1!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#921?email_source=notifications&email_token=AAC35OFURYZCCWEOMYBRK23RCFNYZA5CNFSM4KRUGUMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELIUGTQ#issuecomment-584139598>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC35OFBDV6UPMK25EEWU6DRCFNYZANCNFSM4KRUGUMA>
.
|
Should we move this issue to the 1.x repo? |
I was also seeing this, and it happens with |
Same story happen for me. |
Same --
It seems like the work around is to run |
Some observation from my side. Other thing is... as soon as i enable (node:42700) ExperimentalWarning: The ESM module loader is experimental.
file:///home/dzintars/Code/yarn-test/.yarn/releases/yarn-berry.js:2
[.... some minified long output ....]
ReferenceError: module is not defined
at file:///home/dzintars/Code/yarn-test/.yarn/releases/yarn-berry.js:2:1
at ModuleJob.run (internal/modules/esm/module_job.js:110:37)
at async Loader.import (internal/modules/esm/loader.js:167:24) So.. it looks to me that there are some issues with 2 versions installed on the system. |
Probably this is because yarn's local copy is being loaded as an esm
module, because node thinks it's supposed to do that according to
package.json. I imagine it could be fixed by having yarn emit its own
package.json as a peer to the local copy of yarn.
…On Thu, Feb 20, 2020, 7:59 PM Dzintars Klavins ***@***.***> wrote:
Some observation from my side.
Recently i ditched Yarn 1 & friends from system and set up clean Yarn 2
Berry. The only Yarn on my Linux system. Created some project and it had yarnPath:
.yarn/releases/yarn-rc.js
Today i decided to convert my WebPack configs in TS which lead me again to
Yarns documentation which says that they move to Per-Project installation
workflow which sounds reasonable to me. So i ditched again my Yarn 2, Node,
Npm & frieds (simply to have clean setup). Installed Yarn 1.23 as per
instructions.
Now, when i do yarn set version berry is see .yarnrc.yml created but with
content yarnPath:
"/home/dzintars/Code/yarn-test/.yarn/releases/yarn-berry.js"
Other thing is... as soon as i enable "type": "module", in package.json
Yarn Berry fails to execute even yarn --version with:
(node:42700) ExperimentalWarning: The ESM module loader is experimental.
file:///home/dzintars/Code/github.com/dzintars/yarn-test/.yarn/releases/yarn-berry.js:2
[.... some minified long output ....]
ReferenceError: module is not defined
at file:///home/dzintars/Code//yarn-test/.yarn/releases/yarn-berry.js:2:1
at ModuleJob.run (internal/modules/esm/module_job.js:110:37)
at async Loader.import (internal/modules/esm/loader.js:167:24)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#921?email_source=notifications&email_token=AAC35OBMDMCAQ4KVATI47FTRD4RPXA5CNFSM4KRUGUMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMRD7RQ#issuecomment-589447110>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC35OGKQSQSIIQUKWDF5UTRD4RPXANCNFSM4KRUGUMA>
.
|
Sorry, i can't to get right wording.. but.. when i run |
Correct. The globally-installed yarn will always check if you have a locally-configured copy of yarn. If you do, it will load and delegate to that locally-configured copy. node 13 loads modules as either commonjs or esm depending on a few factors. This page explains how it reads the "type" field from your package.json. Since the local copy of yarn is inside your project's directory, node thinks it's part of your project, and loads it according to the package.json "type" field for your project. yarn can avoid this by emitting another nested package.json within the |
I'm having the same issue and am very confused. Followed the installation instruction using Yarn 1.22.0 on Windows.
The resulting .yarnrc.yml:
|
Seeing the same issue ( |
If you run |
A fix seems to have been merged into the 1.x repo: yarnpkg/yarn#7931 |
Released in 1.22.4 |
Describe the bug
yarn set version berry
writes a.yarnrc.yml
with an absolute path foryarnPath
. I assume this is a bug since the.yarnrc.yml
and.yarn/releases
are meant to be portable and local.To Reproduce
I created a reproduction with Github Actions that can also be copy-pasted to run locally.
https://github.com/cspotcode/repros/tree/yarnrc-absolute-yarnPath
Environment if relevant (please complete the following information):
The text was updated successfully, but these errors were encountered: