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

NX_VERSION_CHANGED for format:write without any further text #29446

Open
4 tasks
ThePlenkov opened this issue Dec 20, 2024 · 3 comments
Open
4 tasks

NX_VERSION_CHANGED for format:write without any further text #29446

ThePlenkov opened this issue Dec 20, 2024 · 3 comments

Comments

@ThePlenkov
Copy link
Contributor

Current Behavior

I mirgrated to a new NX version using nx migrate latest including post-install and run-migrations.

At same time I'm using following husky hook which just worked perfectly:

# .husky/pre-commit
nx format:write --uncommitted --verbose
git update-index --again

So now when I try to commit a change I have some weird error:

> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -

 NX   NX_VERSION_CHANGED


husky - pre-commit script failed (code 1)

If I run nx format:write command separately - it just works. So it does not work from inside the hook.

Unfortunately --verbose flag is useless. nx reset also doesn't not help. Using npx nx also doesn't change anything. Please help!

Expected Behavior

Well nx should work also from git hooks and it should not be impacted by a version change.

I think this check is not working well. Also would be nice even if it's error to have more meaningful explanation

GitHub Repo

No response

Steps to Reproduce

Not sure if you can. But try this.

  • init repo, install nx 19.6.5 ( it's what i had )
  • install husky, add hook as mentioned above, commit.
  • migrate to latest nx
  • commit again

That's what i did..

Nx Report

Node           : 18.20.4
OS             : linux-x64
Native Target  : x86_64-linux
npm            : 10.7.0

nx             : 20.2.2
@nx/js         : 20.2.2
@nx/jest       : 20.2.2
@nx/eslint     : 20.2.2
@nx/workspace  : 20.2.2
@nx/devkit     : 20.2.2
@nx/plugin     : 20.2.2
typescript     : 5.6.3
---------------------------------------
Registered Plugins:
nx-array-args

Failure Logs

Package Manager Version

No response

Operating System

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

Additional Information

No response

@ThePlenkov
Copy link
Contributor Author

So it's funny, i was able to solve this issue by adding nx reset into my hook!

So I tried many time to run nx reset and npx nx reset from the project root - but it had no impact on the hook execution

@ThePlenkov
Copy link
Contributor Author

Actually after few more issues i figured out that just needed to disable daemon:

# .husky/pre-commit
NX_DAEMON=false nx format:write --uncommitted
git update-index --again

@ThePlenkov
Copy link
Contributor Author

However I'd like still to keep this issue open in a hope that someone from nx team can check why daemon in a hook is different from a daemon in a root package and NX_VERSION_CHANGED error occurs

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

No branches or pull requests

1 participant