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
[rush] Rush add causes malformed package.json if the package.json does not have "dependencies" field yet and have >1 entries in "contributors" field
#4811
Open
kenrick95 opened this issue
Jun 27, 2024
· 0 comments
· May be fixed by #4813
If there are >1 contributors in package.json and there is no dependencies yet, running rush add --package <pkg-name> will cause the package.json to be malformed.
➜ pkg-a git:(master) ✗ rush add --package meow
Found configuration in /path/to/repo/rush-repro-rush-add/rush.json
Rush Multi-Project Build Tool 5.124.6 - https://rushjs.io
Node.js version is 18.20.3 (LTS)
Found configuration in /path/to/repo/rush-repro-rush-add/rush.json
Starting "rush add"
Determining new version for dependency: meow
No version selector was specified, so the version will be determined automatically.
Trying to acquire lock for pnpm-8.15.8
Acquired lock for pnpm-8.15.8
Found pnpm version 8.15.8 in /path/to/user/.rush/node-v18.20.3/pnpm-8.15.8
Symlinking "/path/to/repo/rush-repro-rush-add/common/temp/pnpm-local"
--> "/path/to/user/.rush/node-v18.20.3/pnpm-8.15.8"
The "ensureConsistentVersions" policy is NOT active, so we will assign the latest version.
Querying NPM registry for latest version of "meow"...
Found latest version: 13.2.0
Assigning version "~13.2.0" for "meow".
Updating projects to use meow@~13.2.0
Wrote/path/to/repo/rush-repro-rush-add/pkg-a/package.json
Running "rush update"
Checking Git policy for this repository.
Trying to acquire lock for pnpm-8.15.8
Acquired lock for pnpm-8.15.8
Found pnpm version 8.15.8 in /path/to/user/.rush/node-v18.20.3/pnpm-8.15.8
Symlinking "/path/to/repo/rush-repro-rush-add/common/temp/pnpm-local"
--> "/path/to/user/.rush/node-v18.20.3/pnpm-8.15.8"
Transforming /path/to/repo/rush-repro-rush-add/common/config/rush/.npmrc
--> "/path/to/repo/rush-repro-rush-add/common/temp/.npmrc"
Updating workspace files in /path/to/repo/rush-repro-rush-add/common/temp
Copying "/path/to/repo/rush-repro-rush-add/common/config/rush/pnpm-lock.yaml"
--> "/path/to/repo/rush-repro-rush-add/common/temp/pnpm-lock.yaml"
Copying "/path/to/repo/rush-repro-rush-add/common/config/rush/pnpm-lock.yaml"
--> "/path/to/repo/rush-repro-rush-add/common/temp/pnpm-lock-preinstall.yaml"
Checking installation in "/path/to/repo/rush-repro-rush-add/common/temp"
Deleting files from /path/to/repo/rush-repro-rush-add/common/temp/node_modules
Running "pnpm install" in /path/to/repo/rush-repro-rush-add/common/temp
ERR_PNPM_JSON_PARSE Unexpected token "}" (0x7D) in JSON at position 287 while parsing near "...meow\": \"~13.2.0\",\n }\n}\n" in /path/to/repo/rush-repro-rush-add/pkg-a/package.json
15 | "dependencies": {
16 | "meow": "~13.2.0",
> 17 | }
| ^
18 | }
19 |
The command failed:
/path/to/repo/rush-repro-rush-add/common/temp/pnpm-local/node_modules/.bin/pnpm install --store /path/to/repo/rush-repro-rush-add/common/temp/pnpm-store --config.cacheDir=/path/to/repo/rush-repro-rush-add/common/temp/pnpm-store --config.stateDir=/path/to/repo/rush-repro-rush-add/common/temp/pnpm-store --no-prefer-frozen-lockfile --no-strict-peer-dependencies --config.auto-install-peers=false --config.resolutionMode=highest --config.ignoreCompatibilityDb --recursive --link-workspace-packages false --reporter default
ERROR: Error: The command failed with exit code 1
Giving up after 1 attempts
ERROR: The command failed with exit code 1
Details
Standard questions
Please answer these questions to help us investigate your issue more quickly:
Question
Answer
@microsoft/rush globally installed version?
5.117.8
rushVersion from rush.json?
5.129.6
useWorkspaces from rush.json?
Yes
Operating system?
Mac
Would you consider contributing a PR?
Yes
Node.js version (node -v)?
18.20.3
The text was updated successfully, but these errors were encountered:
Summary
If there are >1 contributors in package.json and there is no dependencies yet, running
rush add --package <pkg-name>
will cause the package.json to be malformed.Repro steps
https://github.com/kenrick95/rush-repro-rush-add-malformed-package-json
Check
pkg-a/package.json
:Repro:
cd pkg-a rush add --package meow
Expected result:
Actual result:
Details
Standard questions
Please answer these questions to help us investigate your issue more quickly:
@microsoft/rush
globally installed version?rushVersion
from rush.json?useWorkspaces
from rush.json?node -v
)?The text was updated successfully, but these errors were encountered: