Skip to content

[Bug?]: yarn init generates invalid entries in package.json starting from rc29Β #5090

@ambasta

Description

@ambasta

Self-service

  • I'd be willing to implement a fix

Describe the bug

yarn 'packages/project' init incorrectly populates pacakge.json with values '${projectRootAbsPath}/.yarnrc.yml' and null when nested configuration is specified in initFields in .yarnrc.yml

To reproduce

mkdir projectroot
cd projectroot
yarn init -2
yarn set version 4.0.0-rc.31 # 29/30/31 all fail similarly

echo "
initFields:
  author:
    email: [email protected]
    name: First Last

initScope: somescope
" >> .yarnrc.yml

yarn packages/somepkg init

This generates unexpected entries in projectroot/somepk/package.json

{
  "author": {
    "email": [
      "/home/ambasta/projectroot/.yarnrc.yml",
      "[email protected]",
      null
    ],
    "name": [
      "/home/ambasta/projectroot/.yarnrc.yml",
      "First Last",
      null
    ]
  },
  "name": "@somescope/somepkg",
  "packageManager": "[email protected]"
}

Environment

System:
    OS: Linux 5.19 Gentoo/Linux
    CPU: (8) x64 AMD Ryzen 5 PRO 2500U w/ Radeon Vega Mobile Gfx
  Binaries:
    Node: 18.12.1 - /tmp/xfs-b99129f6/node
    Yarn: 4.0.0-rc.31 - /tmp/xfs-b99129f6/yarn

Additional context

This issue only occurs from rc29 onwards. rc28 and older generate package.json correctly

yarn set version 
yarn packages/blue init
cat packages/blue/package.json

outputs

{
  "author": {
    "email": "[email protected]",
    "name": "First Last"
  },
  "name": "@somescope/blue",
  "packageManager": "[email protected]"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions