nrwl / nx

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

`nx migrate latest` does not work with pnpm #28991

Open kasir-barati opened 2 days ago

kasir-barati commented 2 days ago

Current Behavior

I first thought it is a question, thus I asked it here. But as you can see there this nx upgrade latest does not work for me at all.

I am using pnpm and even if I switch back to npm for a sec to update nx it and switch back to pnpm it does not work.

So to sum it up, we have two issues:

  1. When using pnpm the nx migrate latest does nothing except updating you nx.json and you package.json stays untouched. No migrations.json too.
  2. When I switch to npm for a quick check it does update package.json and nx.json which is not entirely desirable (I mean I want it to work with pnpm and I should not have to switch my package manager to just get it to work) but still it fails to create a migrations.json file.

    Though in your doc you're saing "A migrations.json being generated if there are pending migrations.", which I guess meant to say if it was not generated then you do not need it. Thus I guess I am fine on that part.

    But the issue is when I try then to run nx serve hello-world. It fails to run it when I switch back to pnpm. Note that it does work if I stay with npm. But I do not wanna.

Expected Behavior

Just migrate it.

GitHub Repo

https://github.com/kasir-barati/graphql

Steps to Reproduce

  1. pnpm i.
  2. nx migrate latest.

And then you can see that it does not even bother updating my package.json

  1. rm -rf node_modules tmp dist .nx.
  2. rm pnpm-lock.yaml.
  3. npm i.
  4. nx migrate latest.
  5. npm i.
  6. nx serve hello-world.
  7. You should see some logs in your terminal. It is not doing anything fancy and it is not even a webserver, so it does exit afterward.
  8. rm package-lock.json.
  9. rm -rf node_modules tmp dist .nx
  10. pnpm i.
  11. nx serve hello-world.
  12. It breaks with this log:
 NX   Daemon process terminated and closed the connection

Please rerun the command, which will restart the daemon.
If you get this error again, check for any errors in the daemon process logs found in: /home/kasir/projects/graphql/.nx/workspace-data/d/daemon.log

And then here is what is logged in that file:

https://pastebin.com/GAmP4ctH

It was really long, so I decided to upload it in pastebin.

BTW nx reset did not help.

Nx Report

It seems as if Nx's cli is entirely crashed. this command also generates the same log:

nx report

 NX   Daemon process terminated and closed the connection

Please rerun the command, which will restart the daemon.
If you get this error again, check for any errors in the daemon process logs found in: /home/kasir/projects/graphql/.nx/workspace-data/d/daemon.log

And here is what it logged in that file: https://pastebin.com/fWm2fQ05

Again, too long to be pasted here IMO thus it is pasted in pastebin.

Failure Logs

All logs were provided in previous steps

Package Manager Version

pnpm:9.6.0

Operating System

Additional Information

No response

kasir-barati commented 2 days ago

JFYI: I also tried to update my packages to latest since most of the times nx generators does install versions that ain't latest. So I keep them up to date with pnpm. But pnpm update --latest will update everything in my package.json including @nx/* which is not desirable at all. But at the same time when you say skip any lib starting with @nx/* it throws this error.

Now I feel my issue is turning from a simple issue to a chicken and egg problem ♾.