berry: [Bug] `yarn set version berry` writes absolute (non-portable) path into .yarnrc.yml

  • I’d be willing to implement a fix

Describe the bug

yarn set version berry writes a .yarnrc.yml with an absolute path for yarnPath. 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):

  • OS: Ubuntu
  • Node version v12.15.0
  • Yarn version 2.0.0-rc.28

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 19
  • Comments: 16 (3 by maintainers)

Most upvoted comments

Same –

  1. Per instructions, installed yarn 1.22 as global
  2. Ran yarn set version berry
    • this created .yarnrc.yml with the absolute path to .yarn/yarn-rc.yml
  3. Ran yarn set version berry
    • this set .yarnrc.yml with the relative path to .yarn/yarn-rc.yml

It seems like the work around is to run yarn set version berry twice in a row, until they update the global yarn install version.

A fix seems to have been merged into the 1.x repo: https://github.com/yarnpkg/yarn/pull/7931

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 led me again to Yarn’s 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. + Node 13.9.0, Npm 6.13.7 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/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.