[BUG] specific diff3 conflict is not parsed
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
Current Behavior
When package-lock.json is conflicted, I believe npm has some functionality to automatically resolve the conflicts when you npm install. However, this doesn't work consistently when git is configured to use diff3 conflict markers – here I get a "must provide string spec" error, much like #2117:
$ npm i
npm ERR! must provide string spec
npm ERR! A complete log of this run can be found in: /Users/ah37/.npm/_logs/2023-11-13T16_41_08_559Z-debug-0.log
That log contains the following stack trace:
35 verbose stack TypeError: must provide string spec
35 verbose stack at new Edge (/nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/edge.js:68:13)
35 verbose stack at #loadDepType (/nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:896:9)
35 verbose stack at [Arborist.Node._loadDeps] (/nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:874:22)
35 verbose stack at new Node (/nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:260:20)
35 verbose stack at #loadNode (/nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js:261:18)
35 verbose stack at #resolveNodes (/nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js:190:43)
35 verbose stack at #loadFromShrinkwrap (/nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js:90:48)
35 verbose stack at Arborist.loadVirtual (/nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js:63:35)
35 verbose stack at async Arborist.buildIdealTree (/nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:193:7)
35 verbose stack at async Promise.all (index 1)
Expected Behavior
I'd hoped that npm would be able to understand both regular conflict markers and the (more useful) diff3 markers.
The error can, however, be worked around via git checkout --conflict=merge package-lock.json.
Steps To Reproduce
- Get into a state where your package-lock.json contains a merge conflict
- Run
git checkout --conflict=diff3 package-lock.jsonto make sure it uses diff3 markers - Run
npm i - See "must provide string spec" error
Environment
- npm: 9.8.1
- Node.js: 18.18.2
- OS Name: macOS Ventura 13.6.1
- System Model Name: MacBook Pro
- npm config:
; node bin location = /nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/bin/node
; node version = v18.18.2
; npm local prefix = /Users/ah37
; npm version = 9.8.1
; cwd = /Users/ah37
; HOME = /Users/ah37
; Run `npm config ls -l` to show all defaults.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce with a conflicted package-lock.json using git checkout --conflict=diff3, then run npm i; inspect the stack's @npmcli/arborist files, especially lib/edge.js and lib/node.js. Done means npm accepts diff3 conflict markers as well as regular markers without the "must provide string spec" error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100