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

fix(core): fix package manager determination logic #28546

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ThePlenkov
Copy link
Contributor

Recreated from #28202

Current Behavior

Currently create-nx-workspace determines package manager based on the invoker's path and it might be totally misleading if some names are used in the path such as /ubuntu/my_project which is identified as bun command by mistake

Expected Behavior

It should correctly identify package manager

Related Issue(s)

Fixes #28201

Copy link

vercel bot commented Oct 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Jan 14, 2025 4:22pm

Copy link

nx-cloud bot commented Oct 21, 2024

View your CI Pipeline Execution ↗ for commit a4a9b75.

Command Status Duration Result
nx-cloud record -- nx format:check --base=cbfc6... ❌ Failed 27s View ↗
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 1m 29s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 26s View ↗
nx documentation --no-dte ✅ Succeeded 48s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-14 16:28:22 UTC

@ThePlenkov
Copy link
Contributor Author

picked up wrong commit - updating the branch now..

@ThePlenkov ThePlenkov requested a review from a team as a code owner October 21, 2024 19:16
@ThePlenkov
Copy link
Contributor Author

@JamesHenry let's see if it works now. Is it a right way to create PR? ( from the fork branch, not from master )

@JamesHenry JamesHenry changed the title Fix package manager determintation fix(core): fix package manager determination logic Oct 21, 2024
@JamesHenry
Copy link
Collaborator

Yes looks good, thank you.

The error still persists. I am working on something else right now, but upon a quick try, it is reproducible locally with:

pnpm nx run e2e-workspace-create:e2e-ci--src/create-nx-plugin.test.ts --skip-nx-cache

Please can you take a look?

You can run with NX_E2E_EDITOR= with your code editor of choice's CLI to open the test workspaces in an editor and not tear them down so that further digging is possible.

E.g. for VSCode (as long as you have the code command in your PATH):

NX_E2E_EDITOR=code pnpm nx run e2e-workspace-create:e2e-ci--src/create-nx-plugin.test.ts --skip-nx-cache

@ThePlenkov
Copy link
Contributor Author

Somehow it is still waiting for dependent tasks . Curious how we can run only failing test

image

@JamesHenry
Copy link
Collaborator

You can run without --skip-nx-cache to not run everything from scratch, I just gave that to ensure accuracy when isolating this one piece

@ThePlenkov
Copy link
Contributor Author

pnpm exec nx run e2e-workspace-create:e2e-ci--src/create-nx-plugin.test.ts 

   ⠋  Nx is waiting on 68 dependent project tasks before running tasks from e2e-workspace-create...

——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target e2e-ci--src/create-nx-plugin.test.ts for project e2e-workspace-create and 68 task(s) they depend on (3s)

   ✖  0/0 failed
   ✔  0/0 succeeded [0 read from cache]

View structured, searchable error logs at https://staging.nx.app/runs/WRfGG8terB


 NX   No such file or directory (os error 2)

Pass --verbose to see the stacktrace.

@ThePlenkov
Copy link
Contributor Author

so somehow nx run nx:build-native is failing

@JamesHenry
Copy link
Collaborator

Do you have rust installed?

You'll need to follow all steps in the https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md

@ThePlenkov
Copy link
Contributor Author

I open it via devcontainer - not sure if it's installed indeed

@ThePlenkov
Copy link
Contributor Author

image
rust is there for sure

@ThePlenkov
Copy link
Contributor Author

following this guide you mention i was trying to run nx e2e e2e-workspace-create and it was not working, but e2e-local ran something. May be guide needs to be updated a bit

@ThePlenkov
Copy link
Contributor Author

So this command is failing now: nx e2e-local e2e-workspace-create --verbose and i cannot figure out from where this No such file or directory (os error 2) error comes from

@JamesHenry
Copy link
Collaborator

JamesHenry commented Nov 4, 2024

@ThePlenkov I think the side-effect of correctly picking up pnpm (in the case of our repo) was that it was being passed an invalid --yes param which doesn't apply to pnpm exec, I pushed a commit to try and address this and run CI again

@xiongemi
Copy link
Collaborator

xiongemi commented Dec 2, 2024

i think the plugin fix is also in pr #28949

@xiongemi xiongemi force-pushed the fix-package-manager-determintation branch from 9e1b96e to d3a6265 Compare January 9, 2025 19:36
@xiongemi xiongemi force-pushed the fix-package-manager-determintation branch from d3a6265 to 1ebce5f Compare January 10, 2025 00:47
Copy link
Collaborator

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So happy to see this green now, thanks again @ThePlenkov!

Please let's add some simple unit test coverage using realistic values for the relevant process.env properties for each supported package manager.

It will help folks understand how this works and protect against some basic regressions

packages/create-nx-workspace/src/utils/package-manager.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

/bin/sh: 1: bun: not found
3 participants