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

npx nx migrate latest Failed to install the latest version of the migration script. Using the current version. #26926

Closed
1 of 4 tasks
jahusa02 opened this issue Jul 13, 2024 · 7 comments · Fixed by #27032
Closed
1 of 4 tasks
Assignees
Labels

Comments

@jahusa02
Copy link

Current Behavior

npx nx migrate latest throws error for install script

Expected Behavior

should not throw an error

GitHub Repo

No response

Steps to Reproduce

Dunno if its related but I have a private Registry defined.

  1. run npx nx migrate latest

Nx Report

Node   : 20.15.0
OS     : darwin-arm64
npm    : 10.8.2

nx                 : 19.4.3
@nx/js             : 19.4.3
@nx/jest           : 19.4.3
@nx/linter         : 19.4.3
@nx/eslint         : 19.4.3
@nx/workspace      : 19.4.3
@nx/angular        : 19.4.3
@nx/cypress        : 19.4.3
@nx/devkit         : 19.4.3
@nx/esbuild        : 19.4.3
@nx/eslint-plugin  : 19.4.3
@nx/express        : 19.4.3
@nx/node           : 19.4.3
@nrwl/tao          : 19.4.3
@nx/vite           : 19.4.3
@nx/web            : 19.4.3
@nx/webpack        : 19.4.3
typescript         : 5.5.3
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin
@nx/jest/plugin
@nx/cypress/plugin
---------------------------------------
Community plugins:
@jsverse/transloco        : 7.4.2
@koliveira15/nx-sonarqube : 4.1.0
@ngrx/component-store     : 18.0.1
@ngrx/effects             : 18.0.1
@ngrx/entity              : 18.0.1
@ngrx/eslint-plugin       : 18.0.1
@ngrx/operators           : 18.0.1
@ngrx/router-store        : 18.0.1
@ngrx/schematics          : 18.0.1
@ngrx/store               : 18.0.1
@ngrx/store-devtools      : 18.0.1
@nx-tools/nx-container    : 6.0.1
ng-mocks                  : 14.13.0
ngx-matomo-client         : 6.2.0

Failure Logs

Failed to install the latest version of the migration script. Using the current version.
Error: Command failed: npm install
    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at checkExecSyncError (node:child_process:890:11)
    at execSync (node:child_process:962:15)
    at nxCliPath (/Users/reneachtelik/workspace/fhp-bike/node_modules/nx/src/command-line/migrate/command-object.js:137:38)
    at runMigration (/Users/reneachtelik/workspace/fhp-bike/node_modules/nx/src/command-line/migrate/command-object.js:90:19)
    at Object.handler (/Users/reneachtelik/workspace/fhp-bike/node_modules/nx/src/command-line/migrate/command-object.js:18:9)
    at /Users/reneachtelik/workspace/fhp-bike/node_modules/yargs/build/index.cjs:1:8993
    at j (/Users/reneachtelik/workspace/fhp-bike/node_modules/yargs/build/index.cjs:1:4956)
    at _.handleValidationAndGetResult (/Users/reneachtelik/workspace/fhp-bike/node_modules/yargs/build/index.cjs:1:8962) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 36628,
  stdout: null,
  stderr: null
}

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@FrozenPandaz
Copy link
Collaborator

Could you tell us more about how you have the local registry defined please?

@jahusa02
Copy link
Author

It's not local but remote (Sonatype Nexus).

I have it defined via .npmrc in the root of the project with these settings:

registry=https://nexus-repo.domain.xyz/repository/npm-group/
//nexus-repo.domain.xyz/repository/npm-group/:_auth=BASE64_ENCODED_TOKEN

@leosvelperez
Copy link
Member

@jahusa02 This particular issue might not be related to the registry. I think it's more likely to be related to something specific to your environment, potentially permissions, or something similar.

Given that it might be hard to reproduce (I already tried and couldn't), would you be willing to make a local change to the installed nx package in your node_modules so we can get more logs?

If so, please update the line 167 of the file node_modules/nx/src/command-line/migrate/command-object.js with the following:

-      stdio: ['ignore', 'ignore', 'ignore'],
+      stdio: 'inherit',

Then run npx nx migrate latest again and share the logs here 🙏🏻

As an aside, nx migrate could really use more logging for debugging purposes, so users don't need to manually update their installed packages. I'll look at that separately.

@jahusa02
Copy link
Author

I tried the same thing on my windows system and it threw the same error.

When I changed the stdio to inherit, it indeed shows the registry as the error reason.

0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
1 info using npm@10.8.1
2 info using node@v20.15.1
3 silly config load:file:C:\ProgramData\nvm\v20.15.1\node_modules\npm\npmrc
4 silly config load:file:C:\Users\XXX\AppData\Local\Temp\tmp-41024-Kt7ZUomestxy\.npmrc
5 silly config load:file:C:\Users\XXX\.npmrc
6 silly config load:file:C:\Program Files\nodejs\etc\npmrc
7 verbose title npm install
8 verbose argv "install"
9 verbose logfile logs-max:10 dir:H:\CACHE\npm\_logs\2024-07-22T04_55_25_135Z-
10 verbose logfile H:\CACHE\npm\_logs\2024-07-22T04_55_25_135Z-debug-0.log
11 silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
12 silly logfile start cleaning logs, removing 1 files
13 silly logfile done cleaning log files
14 silly idealTree buildDeps
15 silly fetch manifest nx@latest
16 silly packumentCache full:https:/nexus-repo.domain.xyz/repository/npm-group/nx cache-miss
17 http fetch GET 401 https:/nexus-repo.domain.xyz/repository/npm-group/nx 83ms (cache skip)
18 silly placeDep ROOT nx@ OK for:  want: latest
19 verbose stack HttpErrorAuthUnknown: Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
19 verbose stack     at C:\ProgramData\nvm\v20.15.1\node_modules\npm\node_modules\npm-registry-fetch\lib\check-response.js:80:17
19 verbose stack     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
19 verbose stack     at async RegistryFetcher.packument (C:\ProgramData\nvm\v20.15.1\node_modules\npm\node_modules\pacote\lib\registry.js:90:19)
19 verbose stack     at async RegistryFetcher.manifest (C:\ProgramData\nvm\v20.15.1\node_modules\npm\node_modules\pacote\lib\registry.js:128:23)
19 verbose stack     at async #fetchManifest (C:\ProgramData\nvm\v20.15.1\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1199:20)
19 verbose stack     at async #nodeFromEdge (C:\ProgramData\nvm\v20.15.1\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1037:19)
19 verbose stack     at async #buildDepStep (C:\ProgramData\nvm\v20.15.1\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:901:11)
19 verbose stack     at async Arborist.buildIdealTree (C:\ProgramData\nvm\v20.15.1\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:181:7)
19 verbose stack     at async Promise.all (index 1)
19 verbose stack     at async Arborist.reify (C:\ProgramData\nvm\v20.15.1\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:131:5)
20 verbose statusCode 401
21 verbose pkgid nx@latest
22 error code E401
23 error Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
24 silly unfinished npm timer reify 1721624125502
25 silly unfinished npm timer reify:loadTrees 1721624125506
26 verbose cwd C:\Users\XXX\AppData\Local\Temp\tmp-41024-Kt7ZUomestxy
27 verbose os Windows_NT 10.0.22631
28 verbose node v20.15.1
29 verbose npm  v10.8.1
30 verbose exit 1
31 verbose code 1
32 error A complete log of this run can be found in: H:\CACHE\npm\_logs\2024-07-22T04_55_25_135Z-debug-0.log

@leosvelperez
Copy link
Member

@jahusa02 thanks for sharing the extra logs. It seems the issue is we don't copy the workspace .npmrc file to the temp folder where we install the latest version. I'll send a fix for that.

@jahusa02
Copy link
Author

@leosvelperez thank you for the fast reply and solution!

FrozenPandaz pushed a commit that referenced this issue Jul 22, 2024
…x version in nx migrate (#27032)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #26926

(cherry picked from commit 0bc8898)
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants