node-core-utils icon indicating copy to clipboard operation
node-core-utils copied to clipboard

Error message from `git-node v8 backport` is less helpful than in [email protected]

Open richardlau opened this issue 1 year ago • 4 comments

Attempted to backport a commit that doesn't exist yet.

With [email protected]:

$ npx [email protected] -- git-node v8 backport df5724c11697b4fbe803adcb5a51020dea2d923f
Need to install the following packages:
[email protected]
Ok to proceed? (y) y
npm WARN deprecated [email protected]: This package has been renamed to @node-core/utils
(node:1406084) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
✔ Update local V8 clone
⠦ V8 commit backport
fatal: ambiguous argument 'df5724c11697b4fbe803adcb5a51020dea2d923f
^..df5724c11697b4fbe803adcb5a51020dea2d923f
': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'df5724c11697b4fbe803adcb5a51020dea2d923f
': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
$

With @node-core/[email protected]:

$ npx --package=@node-core/utils@latest -- git-node v8 backport df5724c11697b4fbe803adcb5a51020dea2d923f
Need to install the following packages:
@node-core/[email protected]
Ok to proceed? (y) y
✔ Update local V8 clone
❯ V8 commit backport
  ✔ Get current V8 version
  ✔ Generate patches
  ❯ Apply and commit patches to deps/v8
    ❯ Commit df5724c11697
      ✔ Apply patch
      ✔ Increment embedder version number
      ✖ Cannot read properties of undefined (reading 'replace')
✖ Cannot read properties of undefined (reading 'replace')
$

The error from the older version is a lot more indicative of what the actual problem is.

richardlau avatar May 01 '24 12:05 richardlau

It looks like the expected error doesn't happen anymore, or is somehow swallowed.

targos avatar May 01 '24 12:05 targos

I guess maybe being swallowed?

$ NCU_VERBOSITY=debug npx --package=@node-core/utils@latest -- git-node v8 backport df5724c11697b4fbe803adcb5a51020dea2d923f
✔ Update local V8 clone
❯ V8 commit backport
  ✔ Get current V8 version
  ✔ Generate patches
  ❯ Apply and commit patches to deps/v8
    ❯ Commit df5724c11697
      ✔ Apply patch
      ✔ Increment embedder version number
      ✖ Cannot read properties of undefined (reading 'replace')


[DEBUG] [Spawn] git fetch origin { cwd: '/home/rlau/.update-v8/v8', stdio: 'ignore' }

[DEBUG] [Spawn] git rev-parse df5724c11697b4fbe803adcb5a51020dea2d923f {
  cwd: '/home/rlau/.update-v8/v8',
  stdio: [ 'ignore', 'pipe', 'ignore' ]
}

[DEBUG] [Spawn] git format-patch --stdout df5724c11697b4fbe803adcb5a51020dea2d923f^..df5724c11697b4fbe803adcb5a51020dea2d923f {
  cwd: '/home/rlau/.update-v8/v8',
  stdio: [ 'ignore', 'pipe', 'ignore' ]
}

[DEBUG] [Spawn] git log --format=%B -n 1 df5724c11697b4fbe803adcb5a51020dea2d923f {
  cwd: '/home/rlau/.update-v8/v8',
  stdio: [ 'ignore', 'pipe', 'ignore' ]
}

[DEBUG] [Spawn] git apply -p1 --3way --directory=deps/v8 { cwd: '/home/rlau/sandbox/github/node', stdio: 'ignore' }

[DEBUG] [Spawn] git add common.gypi { cwd: '/home/rlau/sandbox/github/node', stdio: 'ignore' }
✖ Cannot read properties of undefined (reading 'replace')
$

The git format-patch command should fail (with error message matching that from [email protected]):

$ pwd
/home/rlau/.update-v8/v8
$ git format-patch --stdout df5724c11697b4fbe803adcb5a51020dea2d923f^..df5724c11697b4fbe803adcb5a51020dea2d923f
fatal: ambiguous argument 'df5724c11697b4fbe803adcb5a51020dea2d923f^..df5724c11697b4fbe803adcb5a51020dea2d923f': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
$ echo $?
128
$

I couldn't seem to get NCU_VERBOSITY to output any extra info with [email protected]. I tried with this patch:

diff --git a/components/git/v8.js b/components/git/v8.js
index 05e49a2..1cc9574 100644
--- a/components/git/v8.js
+++ b/components/git/v8.js
@@ -92,7 +92,7 @@ export function handler(argv) {
   options.execGitV8 = function execGitV8(...args) {
     return forceRunAsync('git', args, {
       captureStdout: true,
-      spawnArgs: { cwd: options.v8Dir, stdio: ['ignore', 'pipe', 'ignore'] }
+      spawnArgs: { cwd: options.v8Dir, stdio: ['ignore', 'pipe', 'inherit'] }
     });
   };

but this still doesn't capture the error (note the debug output shows that inherit is being used):

$ NCU_VERBOSITY=debug node /home/rlau/sandbox/github/node-core-utils/bin/git-node.js v8 backport df5724c11697b4fbe803adcb5a51020dea2d923f
✔ Update local V8 clone
⠴ V8 commit backport
fatal: ambiguous argument 'df5724c11697b4fbe803adcb5a51020dea2d923f^..df5724c11697b4fbe803adcb5a51020dea2d923f': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
✔ Update local V8 clone
❯ V8 commit backport
  ✔ Get current V8 version
  ✔ Generate patches
  ❯ Apply and commit patches to deps/v8
    ❯ Commit df5724c11697
      ✔ Apply patch
      ✔ Increment embedder version number
      ✖ Cannot read properties of undefined (reading 'replace')


[DEBUG] [Spawn] git fetch origin { cwd: '/home/rlau/.update-v8/v8', stdio: 'ignore' }

[DEBUG] [Spawn] git rev-parse df5724c11697b4fbe803adcb5a51020dea2d923f {
  cwd: '/home/rlau/.update-v8/v8',
  stdio: [ 'ignore', 'pipe', 'inherit' ]
}

[DEBUG] [Spawn] git format-patch --stdout df5724c11697b4fbe803adcb5a51020dea2d923f^..df5724c11697b4fbe803adcb5a51020dea2d923f {
  cwd: '/home/rlau/.update-v8/v8',
  stdio: [ 'ignore', 'pipe', 'inherit' ]
}

[DEBUG] [Spawn] git log --format=%B -n 1 df5724c11697b4fbe803adcb5a51020dea2d923f {
  cwd: '/home/rlau/.update-v8/v8',
  stdio: [ 'ignore', 'pipe', 'inherit' ]
}

[DEBUG] [Spawn] git apply -p1 --3way --directory=deps/v8 { cwd: '/home/rlau/sandbox/github/node', stdio: 'ignore' }

[DEBUG] [Spawn] git add common.gypi { cwd: '/home/rlau/sandbox/github/node', stdio: 'ignore' }
✖ Cannot read properties of undefined (reading 'replace')
$

richardlau avatar May 01 '24 17:05 richardlau

Neither does changing to pipe:

diff --git a/components/git/v8.js b/components/git/v8.js
index 05e49a2..95b5898 100644
--- a/components/git/v8.js
+++ b/components/git/v8.js
@@ -92,7 +92,7 @@ export function handler(argv) {
   options.execGitV8 = function execGitV8(...args) {
     return forceRunAsync('git', args, {
       captureStdout: true,
-      spawnArgs: { cwd: options.v8Dir, stdio: ['ignore', 'pipe', 'ignore'] }
+      spawnArgs: { cwd: options.v8Dir, stdio: ['ignore', 'pipe', 'pipe'] }
     });
   };

$ NCU_VERBOSITY=debug node /home/rlau/sandbox/github/node-core-utils/bin/git-node.js v8 backport df5724c11697b4fbe803adcb5a51020dea2d923f
✔ Update local V8 clone
❯ V8 commit backport
  ✔ Get current V8 version
  ✔ Generate patches
  ❯ Apply and commit patches to deps/v8
    ❯ Commit df5724c11697
      ✔ Apply patch
      ✔ Increment embedder version number
      ✖ Cannot read properties of undefined (reading 'replace')


[DEBUG] [Spawn] git fetch origin { cwd: '/home/rlau/.update-v8/v8', stdio: 'ignore' }

[DEBUG] [Spawn] git rev-parse df5724c11697b4fbe803adcb5a51020dea2d923f {
  cwd: '/home/rlau/.update-v8/v8',
  stdio: [ 'ignore', 'pipe', 'pipe' ]
}

[DEBUG] [Spawn] git format-patch --stdout df5724c11697b4fbe803adcb5a51020dea2d923f^..df5724c11697b4fbe803adcb5a51020dea2d923f {
  cwd: '/home/rlau/.update-v8/v8',
  stdio: [ 'ignore', 'pipe', 'pipe' ]
}

[DEBUG] [Spawn] git log --format=%B -n 1 df5724c11697b4fbe803adcb5a51020dea2d923f {
  cwd: '/home/rlau/.update-v8/v8',
  stdio: [ 'ignore', 'pipe', 'pipe' ]
}

[DEBUG] [Spawn] git apply -p1 --3way --directory=deps/v8 { cwd: '/home/rlau/sandbox/github/node', stdio: 'ignore' }

[DEBUG] [Spawn] git add common.gypi { cwd: '/home/rlau/sandbox/github/node', stdio: 'ignore' }
✖ Cannot read properties of undefined (reading 'replace')
$

richardlau avatar May 01 '24 17:05 richardlau

https://github.com/nodejs/node-core-utils/pull/809 may help.

targos avatar May 12 '24 08:05 targos