nx icon indicating copy to clipboard operation
nx copied to clipboard

Nx should clear the cache after a migration

Open PowerSupply opened this issue 1 year ago • 3 comments

Current Behavior

Here is a description of the problem that pointed me to the conclusion in the title:

After upgrading to 19.5 from 19.0.4 the dependency-check lint rule started to fail with false negatives.

It said: error The "@nx/devkit" package is not used by "xxx" project

But it is used! And the lint worked before the upgrade to 19.5. Running the command with --skip-nx-cache still fails. But what is weird is that going to the file where @nx/devkit is imported and just making a small inconsequential change to it (like moving the line with the import to being second instead of first) makes the error go away. And then it doesn't appear again.

Runningnx reset and then trying the command again seems to fix it which points to some sort of local cache error. I think Nx should reset itself when migrating to a new version since it seems like the cache becomes dirty. But I do not understand why the error still appeared when i used --skip-nx-cache.

Expected Behavior

The problem I had should not have appeared. Proposed solution is to run nx reset as a part of migration to a new version of nx.

GitHub Repo

No response

Steps to Reproduce

  1. Use Nx 19.0.4. Have a project that passes lint.
  2. Upgrade to Nx 19.5.
  3. Try to run the lint for the same project. It may fail even if it should succeed and making a small inconsequential change to the file where the import is fixes the problem. Nx reset also fixes the problem.

Nx Report

Node           : 18.15.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 9.5.0

nx                 : 19.5.6
@nx/js             : 19.5.6
@nx/jest           : 19.5.6
@nx/linter         : 19.5.6
@nx/eslint         : 19.5.6
@nx/workspace      : 19.5.6
@nx/angular        : 19.5.6
@nx/cypress        : 19.5.6
@nx/devkit         : 19.5.6
@nx/eslint-plugin  : 19.5.6
@nx/playwright     : 19.5.6
@nx/plugin         : 19.5.6
@nrwl/tao          : 19.5.6
@nx/vite           : 19.5.6
@nx/web            : 19.5.6
@nx/webpack        : 19.5.6
typescript         : 5.4.5

Failure Logs

error  The "@nx/devkit" package is not used by "xxx" project

Package Manager Version

No response

Operating System

  • [X] macOS
  • [ ] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

No response

PowerSupply avatar Aug 05 '24 13:08 PowerSupply

Same problem for me. Some libs disappear from the project graph, so the dependency-check can't find them (and other tasks too). And Nx reset doesn't solve the problem. Curiously it only happen on libs where the folder path contains "api" ( 'projects/api/.../project.json), but it's probably a coincidence.

  • I save the project.json file of the lib
  • nx show projects -> the lib returns in the project graph
  • nx reset -> the lib disappear again

pascalmann avatar Aug 06 '24 07:08 pascalmann

I've the problem on Ubuntu 20. It seems ok with @19.4.0.

Maybe resolved with https://github.com/nrwl/nx/pull/27338 ?

pascalmann avatar Aug 10 '24 07:08 pascalmann

~I no longer have the problem with this version "nx": "19.6.2"~.

The problem was elsewhere:

  • I had a .gitignore in the parent folder of my nx repo that affected the native glob method that is used by nx to retriev all project.json files in the workspace.
  • This is a really strange behavior that doesn't happen until 19.4.4.

pascalmann avatar Aug 23 '24 10:08 pascalmann

See https://github.com/nrwl/nx/issues/27368.

pascalmann avatar Sep 02 '24 04:09 pascalmann

This issue has been automatically marked as stale because it hasn't had any activity for 6 months. Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore. If at this point, this is still an issue, please respond with updated information. It will be closed in 21 days if no further activity occurs. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar Mar 02 '25 00:03 github-actions[bot]

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[bot] avatar Apr 23 '25 00:04 github-actions[bot]