nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.26k stars 2.32k forks source link

Nx should clear the cache after a migration #27295

Open PowerSupply opened 1 month ago

PowerSupply commented 1 month ago

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

Additional Information

No response

pascalmann commented 1 month ago

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.

pascalmann commented 1 month ago

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 commented 3 weeks ago

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

The problem was elsewhere:

pascalmann commented 2 weeks ago

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