Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latest nx-ignore failing in vercel with latest nx release #178

Closed
saibs opened this issue Mar 14, 2023 · 16 comments
Closed

latest nx-ignore failing in vercel with latest nx release #178

saibs opened this issue Mar 14, 2023 · 16 comments

Comments

@saibs
Copy link

saibs commented Mar 14, 2023

Since nx 15.7.0 nx-ignore command is failing in vercel with the following error.

I tried degrading to nx 15.6.0 and this command works fine.

npm WARN exec The following package was not found and will be installed: nx-ignore@15.6.0
21:26:24.660 | ≫ Using Nx to determine if this project (app) is affected by the commit...
21:26:24.660 | ≫ Running from /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/nx-ignore/src
21:26:24.660 | ≫ Workspace root is /vercel/path0
21:26:24.665 | ≫ Creating temp folder to install Nx: /tmp/.nx-ignore
21:26:32.482 | npm WARN using --force Recommended protections disabled.
21:26:32.484 | ≫ Found Nx at version 15.7.0
21:26:32.485 |  
21:26:32.485 | ≫ Comparing HEAD^...HEAD
21:26:32.485 |  
21:26:42.141 | node:internal/errors:868
21:26:42.141 | const err = new Error(message);
21:26:42.141 | ^
21:26:42.141 |  
21:26:42.142 | Error: Command failed: npx nx print-affected --base=HEAD^ --head=HEAD
21:26:42.142 | at checkExecSyncError (node:child_process:885:11)
21:26:42.142 | at execSync (node:child_process:957:15)
21:26:42.142 | at /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/nx-ignore/src/index.js:67:24
21:26:42.142 | at Generator.next (<anonymous>)
21:26:42.143 | at asyncGeneratorStep (/vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:13:28)
21:26:42.143 | at _next (/vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:31:17)
21:26:42.143 | at /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:36:13
21:26:42.143 | at new Promise (<anonymous>)
21:26:42.143 | at /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:28:16 {
21:26:42.143 | status: 1,
21:26:42.144 | signal: null,
21:26:42.144 | output: [
21:26:42.144 | null,
21:26:42.144 | Buffer(89) [Uint8Array] [
21:26:42.144 | 10,  32,  62,  32,  32,  78,  88,  32,  32,  32,  67, 111,
21:26:42.144 | 117, 108, 100,  32, 110, 111, 116,  32, 102, 105, 110, 100,
21:26:42.144 | 32,  34,  46, 109, 111, 100, 117, 108, 101, 115,  46, 121,
21:26:42.144 | 97, 109, 108,  34,  32,  97, 116,  32,  34,  47, 118, 101,
21:26:42.144 | 114,  99, 101, 108,  47, 112,  97, 116, 104,  48,  47, 110,
21:26:42.145 | 46, 109, 111, 100, 117, 108, 101, 115,  46, 121,  97, 109,
21:26:42.145 | 108,  34,  10,  10,  10
21:26:42.145 | ],
21:26:42.145 | Buffer(0) [Uint8Array] []
21:26:42.145 | ],
21:26:42.145 | pid: 171,
21:26:42.145 | stdout: Buffer(89) [Uint8Array] [
21:26:42.145 | 10,  32,  62,  32,  32,  78,  88,  32,  32,  32,  67, 111,
21:26:42.146 | 117, 108, 100,  32, 110, 111, 116,  32, 102, 105, 110, 100,
21:26:42.146 | 32,  34,  46, 109, 111, 100, 117, 108, 101, 115,  46, 121,
21:26:42.146 | 97, 109, 108,  34,  32,  97, 116,  32,  34,  47, 118, 101,
21:26:42.146 | 114,  99, 101, 108,  47, 112,  97, 116, 104,  48,  47, 110,
21:26:42.146 | 111, 100, 101,  95, 109, 111, 100, 117, 108, 101, 115,  47,
21:26:42.146 | 46, 109, 111, 100, 117, 108, 101, 115,  46, 121,  97, 109,
21:26:42.146 | 108,  34,  10,  10,  10
21:26:42.146 | ],
21:26:42.146 | stderr: Buffer(0) [Uint8Array] []
21:26:42.147 | }
21:26:42.147

<br class="Apple-interchange-newline">
@saibs
Copy link
Author

saibs commented Mar 19, 2023

I downgraded nx-ignore to 15.5.0 and it's working with latest nx. I believe it's after this change

@saibs saibs changed the title nx-ignore failing in vercel since nx 15.7.0 latest nx-ignore failing in vercel with latest nx release Mar 19, 2023
@mheob
Copy link

mheob commented Mar 20, 2023

I have the same problem since a few days.

...

[09:57:31.592] Cloning completed: 1.434s
[09:57:31.592] Running "npx nx-ignore nrt --verbose"
[09:57:32.868] npm WARN exec The following package was not found and will be installed: nx-ignore@15.6.0
[09:57:33.441] ≫ Using Nx to determine if this project (nrt) is affected by the commit...
[09:57:33.441] ≫ Running from /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/nx-ignore/src
[09:57:33.442] ≫ Workspace root is /vercel/path0
[09:57:33.444] ≫ Creating temp folder to install Nx: /tmp/.nx-ignore
[09:57:40.208] npm WARN using --force Recommended protections disabled.
[09:57:40.211] ≫ Found Nx at version 15.8.1
[09:57:40.211] 
[09:57:40.211] ≫ Validating base ref: d9c2015cae40795d8b93fe49d890f8bf26390fe4
[09:57:40.211] 
[09:57:40.218] 
[09:57:40.218] ≫ Comparing d9c2015cae40795d8b93fe49d890f8bf26390fe4...HEAD
[09:57:40.219] 
[09:57:49.791] node:internal/errors:868
[09:57:49.791]   const err = new Error(message);
[09:57:49.791]               ^
[09:57:49.792] 
[09:57:49.792] Error: Command failed: npx nx print-affected --base=d9c2015cae40795d8b93fe49d890f8bf26390fe4 --head=HEAD
[09:57:49.792]     at checkExecSyncError (node:child_process:885:11)
[09:57:49.792]     at execSync (node:child_process:957:15)
[09:57:49.792]     at /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/nx-ignore/src/index.js:67:24
[09:57:49.792]     at Generator.next (<anonymous>)
[09:57:49.792]     at asyncGeneratorStep (/vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:13:28)
[09:57:49.793]     at _next (/vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:31:17)
[09:57:49.793]     at /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:36:13
[09:57:49.793]     at new Promise (<anonymous>)
[09:57:49.793]     at /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:28:16 {
[09:57:49.793]   status: 1,
[09:57:49.793]   signal: null,
[09:57:49.793]   output: [
[09:57:49.794]     null,
[09:57:49.794]     Buffer(89) [Uint8Array] [
[09:57:49.794]        10,  32,  62,  32,  32,  78,  88,  32,  32,  32,  67, 111,
[09:57:49.794]       117, 108, 100,  32, 110, 111, 116,  32, 102, 105, 110, 100,
[09:57:49.794]        32,  34,  46, 109, 111, 100, 117, 108, 101, 115,  46, 121,
[09:57:49.794]        97, 109, 108,  34,  32,  97, 116,  32,  34,  47, 118, 101,
[09:57:49.794]       114,  99, 101, 108,  47, 112,  97, 116, 104,  48,  47, 110,
[09:57:49.794]       111, 100, 101,  95, 109, 111, 100, 117, 108, 101, 115,  47,
[09:57:49.794]        46, 109, 111, 100, 117, 108, 101, 115,  46, 121,  97, 109,
[09:57:49.795]       108,  34,  10,  10,  10
[09:57:49.795]     ],
[09:57:49.802]     Buffer(0) [Uint8Array] []
[09:57:49.802]   ],
[09:57:49.802]   pid: 170,
[09:57:49.802]   stdout: Buffer(89) [Uint8Array] [
[09:57:49.802]      10,  32,  62,  32,  32,  78,  88,  32,  32,  32,  67, 111,
[09:57:49.804]     117, 108, 100,  32, 110, 111, 116,  32, 102, 105, 110, 100,
[09:57:49.804]      32,  34,  46, 109, 111, 100, 117, 108, 101, 115,  46, 121,
[09:57:49.804]      97, 109, 108,  34,  32,  97, 116,  32,  34,  47, 118, 101,
[09:57:49.804]     114,  99, 101, 108,  47, 112,  97, 116, 104,  48,  47, 110,
[09:57:49.804]     111, 100, 101,  95, 109, 111, 100, 117, 108, 101, 115,  47,
[09:57:49.805]      46, 109, 111, 100, 117, 108, 101, 115,  46, 121,  97, 109,
[09:57:49.805]     108,  34,  10,  10,  10
[09:57:49.805]   ],
[09:57:49.805]   stderr: Buffer(0) [Uint8Array] []
[09:57:49.805] }
[09:57:49.805] 
[09:57:49.805] Node.js v18.13.0
[09:57:52.526] Restored build cache

...

For example, in a deployment two weeks ago, it also worked in version 15.6.0. I therefore think that it does not necessarily have anything to do with the change mentioned. But I am not sure about that.

image

@saibs
Copy link
Author

saibs commented Mar 20, 2023

@mheob two weeks ago what was your nx version? It's not shown in the screenshot probably you didn't have verbose option back then.
As I mentioned in the first comment I noticed the issue after upgrading NX to 15.7.0.
But surprisingly, with latest NX and nx-ignore 15.5.0 worked together fine.
npx nx-ignore@15.5.0 appName --verbose

@mheob
Copy link

mheob commented Mar 21, 2023

@saibs yes, the problem seems to be a mix of the current nx and nx-ingore versions.
I can also reproduce that nx-ignore 15.5.0 still works with the nx version (15.8.1). And the latest nx-ignore (15.6.0) works with nx 15.6.3 for example.


As a side note, my log from two weeks ago was running NX 15.6.3. So, as you mentioned, it worked before nx 15.7.0.

My main point in posting was to clarify that you are not alone in running this issue, but that more people are looking forward to a fix.

@EthanML
Copy link

EthanML commented Jul 11, 2023

This is still occurring for me running the latest versions of both Nx and nx-ignore - any indication of a solution or suggested workaround for this?

@awilderink
Copy link

awilderink commented Jul 20, 2023

I had a similar problem, I looked into the code and noticed they use npm to install a temporary version of nx. If I do this locally it will fail too. If I run the commands in the code with pnpm, it just works fine.

A workaround is use this as a script:

pnpm install && pnpm nx show projects --affected --base=$VERCEL_GIT_PREVIOUS_SHA --head=$VERCEL_GIT_COMMIT_SHA | (! grep -q "<your project>")

This will assume though that you use pnpm and Vercel. So adjust according to your needs

@tom-sherman
Copy link

pnpm dlx nx-ignore@15.5.0 appName was working for a little while but now it breaks with a different error, I'm on nx 16.6.0 but the same happens on 16.7.1

≫ Using Nx to determine if this project (vercel-webhooks) is affected by the commit...
/Users/tom.sherman/Library/pnpm/store/v3/tmp/dlx-93594/node_modules/.pnpm/nx-ignore@15.5.0/node_modules/nx-ignore/src/index.js:28
    _main = swcHelpers.asyncToGenerator(function*() {
                       ^

TypeError: swcHelpers.asyncToGenerator is not a function
    at _main (/Users/tom.sherman/Library/pnpm/store/v3/tmp/dlx-93594/node_modules/.pnpm/nx-ignore@15.5.0/node_modules/nx-ignore/src/index.js:28:24)
    at main (/Users/tom.sherman/Library/pnpm/store/v3/tmp/dlx-93594/node_modules/.pnpm/nx-ignore@15.5.0/node_modules/nx-ignore/src/index.js:25:18)
    at Object.<anonymous> (/Users/tom.sherman/Library/pnpm/store/v3/tmp/dlx-93594/node_modules/.pnpm/nx-ignore@15.5.0/node_modules/nx-ignore/src/index.js:23:1)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.13.0
 ERROR  Command failed with exit code 1: nx-ignore vercel-webhooks

pnpm: Command failed with exit code 1: nx-ignore vercel-webhooks
    at makeError (/Users/tom.sherman/Library/pnpm/global/5/.pnpm/pnpm@8.6.6/node_modules/pnpm/dist/pnpm.cjs:24241:17)
    at handlePromise (/Users/tom.sherman/Library/pnpm/global/5/.pnpm/pnpm@8.6.6/node_modules/pnpm/dist/pnpm.cjs:24812:33)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.handler [as dlx] (/Users/tom.sherman/Library/pnpm/global/5/.pnpm/pnpm@8.6.6/node_modules/pnpm/dist/pnpm.cjs:209241:7)
    at async /Users/tom.sherman/Library/pnpm/global/5/.pnpm/pnpm@8.6.6/node_modules/pnpm/dist/pnpm.cjs:218647:21
    at async main (/Users/tom.sherman/Library/pnpm/global/5/.pnpm/pnpm@8.6.6/node_modules/pnpm/dist/pnpm.cjs:218614:34)
    at async runPnpm (/Users/tom.sherman/Library/pnpm/global/5/.pnpm/pnpm@8.6.6/node_modules/pnpm/dist/pnpm.cjs:2

@tom-sherman
Copy link

@awilderink I tried your workaround and unfortunately it didn't work. I get the following error:



Error: Command failed: git diff --name-only --no-renames --relative "main" "2ccdceb5d2478fa7e74abac215c2366250bd785e"

fatal: ambiguous argument 'main': unknown revision or path not in the working tree.

@tknickman
Copy link

tknickman commented Aug 22, 2023

@tom-sherman checkouts on Vercel are shallow by default, and directly fetch your repo into a newly initialized local git repo, which means the local branch will always be master.

main will not work as a comparison in that build environment. Generally comparisons against HEAD is recommended.

You can verify this by running a test and setting the ignore build script to just:
git branch (the build will be canceled, but you can see the output to verify)

@tom-sherman
Copy link

I wasn't specifying main, I was doing nx show projects --affected --base=$VERCEL_GIT_PREVIOUS_SHA --head=$VERCEL_GIT_COMMIT_SHA

@tknickman
Copy link

Got it!

I noticed it in this error, but looks like that was from a workaround:

Error: Command failed: git diff --name-only --no-renames --relative "main" "2ccdceb5d2478fa7e74abac215c2366250bd785e"

Looks like this is something else then!

@tom-sherman
Copy link

I was able to get @awilderink's workaround working (with the help of @meshaabi 👏) by using corepack in the ignore step to ensure Vercel uses the correct version of pnpm. The ignore step was using pnpm v6 but we're on v8.

corepack enable && corepack prepare pnpm@8.6.6 --activate && pnpm dlx nx show projects --affected --base=$VERCEL_GIT_PREVIOUS_SHA --head=$VERCEL_GIT_COMMIT_SHA | (! grep -q \"< your project >\")

Of course you'll want to match your local pnpm version: I'd recommend placing this version in the packageManager package.json field and changing the prepare command to use this like so:

corepack enable && corepack prepare --activate && pnpm dlx nx show projects --affected --base=$VERCEL_GIT_PREVIOUS_SHA --head=$VERCEL_GIT_COMMIT_SHA | (! grep -q \"< your project >\")

Also, we found that there was no need to install the entire workspace dependencies in the build step. pnpm dlx nx worked fine for us but you may need to specify a version to match your version of nx.

@tom-sherman
Copy link

Just wanted to check back in and say we removed this workaround and instead just not doing nx-ignore because the ignore step became so slow. Additionally, we had private dependencies and vercel doesn't allow injecting any sort of npm token into the ignore step - so this is workaround no longer an option for us.

@tom-sherman
Copy link

#329 fixes this issue for us. We can now do pnpm dlx nx-ignore project-name and everything works!

@EthanML
Copy link

EthanML commented Sep 28, 2023

Awesome news 😄 Thanks for keeping the rest of us posted @tom-sherman

@saibs saibs closed this as completed Oct 4, 2023
@mattleong
Copy link

I have the same problem since a few days.

...

[09:57:31.592] Cloning completed: 1.434s
[09:57:31.592] Running "npx nx-ignore nrt --verbose"
[09:57:32.868] npm WARN exec The following package was not found and will be installed: nx-ignore@15.6.0
[09:57:33.441] ≫ Using Nx to determine if this project (nrt) is affected by the commit...
[09:57:33.441] ≫ Running from /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/nx-ignore/src
[09:57:33.442] ≫ Workspace root is /vercel/path0
[09:57:33.444] ≫ Creating temp folder to install Nx: /tmp/.nx-ignore
[09:57:40.208] npm WARN using --force Recommended protections disabled.
[09:57:40.211] ≫ Found Nx at version 15.8.1
[09:57:40.211] 
[09:57:40.211] ≫ Validating base ref: d9c2015cae40795d8b93fe49d890f8bf26390fe4
[09:57:40.211] 
[09:57:40.218] 
[09:57:40.218] ≫ Comparing d9c2015cae40795d8b93fe49d890f8bf26390fe4...HEAD
[09:57:40.219] 
[09:57:49.791] node:internal/errors:868
[09:57:49.791]   const err = new Error(message);
[09:57:49.791]               ^
[09:57:49.792] 
[09:57:49.792] Error: Command failed: npx nx print-affected --base=d9c2015cae40795d8b93fe49d890f8bf26390fe4 --head=HEAD
[09:57:49.792]     at checkExecSyncError (node:child_process:885:11)
[09:57:49.792]     at execSync (node:child_process:957:15)
[09:57:49.792]     at /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/nx-ignore/src/index.js:67:24
[09:57:49.792]     at Generator.next (<anonymous>)
[09:57:49.792]     at asyncGeneratorStep (/vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:13:28)
[09:57:49.793]     at _next (/vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:31:17)
[09:57:49.793]     at /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:36:13
[09:57:49.793]     at new Promise (<anonymous>)
[09:57:49.793]     at /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:28:16 {
[09:57:49.793]   status: 1,
[09:57:49.793]   signal: null,
[09:57:49.793]   output: [
[09:57:49.794]     null,
[09:57:49.794]     Buffer(89) [Uint8Array] [
[09:57:49.794]        10,  32,  62,  32,  32,  78,  88,  32,  32,  32,  67, 111,
[09:57:49.794]       117, 108, 100,  32, 110, 111, 116,  32, 102, 105, 110, 100,
[09:57:49.794]        32,  34,  46, 109, 111, 100, 117, 108, 101, 115,  46, 121,
[09:57:49.794]        97, 109, 108,  34,  32,  97, 116,  32,  34,  47, 118, 101,
[09:57:49.794]       114,  99, 101, 108,  47, 112,  97, 116, 104,  48,  47, 110,
[09:57:49.794]       111, 100, 101,  95, 109, 111, 100, 117, 108, 101, 115,  47,
[09:57:49.794]        46, 109, 111, 100, 117, 108, 101, 115,  46, 121,  97, 109,
[09:57:49.795]       108,  34,  10,  10,  10
[09:57:49.795]     ],
[09:57:49.802]     Buffer(0) [Uint8Array] []
[09:57:49.802]   ],
[09:57:49.802]   pid: 170,
[09:57:49.802]   stdout: Buffer(89) [Uint8Array] [
[09:57:49.802]      10,  32,  62,  32,  32,  78,  88,  32,  32,  32,  67, 111,
[09:57:49.804]     117, 108, 100,  32, 110, 111, 116,  32, 102, 105, 110, 100,
[09:57:49.804]      32,  34,  46, 109, 111, 100, 117, 108, 101, 115,  46, 121,
[09:57:49.804]      97, 109, 108,  34,  32,  97, 116,  32,  34,  47, 118, 101,
[09:57:49.804]     114,  99, 101, 108,  47, 112,  97, 116, 104,  48,  47, 110,
[09:57:49.804]     111, 100, 101,  95, 109, 111, 100, 117, 108, 101, 115,  47,
[09:57:49.805]      46, 109, 111, 100, 117, 108, 101, 115,  46, 121,  97, 109,
[09:57:49.805]     108,  34,  10,  10,  10
[09:57:49.805]   ],
[09:57:49.805]   stderr: Buffer(0) [Uint8Array] []
[09:57:49.805] }
[09:57:49.805] 
[09:57:49.805] Node.js v18.13.0
[09:57:52.526] Restored build cache

...

For example, in a deployment two weeks ago, it also worked in version 15.6.0. I therefore think that it does not necessarily have anything to do with the change mentioned. But I am not sure about that.

image

I'm seeing this issue with NX v18.2.4 and nx-ignore v18.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants