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 16.7.0 throws in workspaces with plugins when projects have same folder name but different paths #18660

Closed
1 of 4 tasks
JulioC opened this issue Aug 16, 2023 · 1 comment · Fixed by #18665
Closed
1 of 4 tasks
Assignees
Labels

Comments

@JulioC
Copy link
Contributor

JulioC commented Aug 16, 2023

Current Behavior

Consider a workspace like nx-examples, where at least two projects have the same folder name, even if they are different paths:

  • libs/shared/cart/state
  • libs/shared/product/state

When adding a plugin (in nx.json) which implements CreateNodes (v2) or registerProjectTargets (from v1), nx will crash whenever it tries to build the project graph (ie nx report or nx run-many -t build --all).

Expected Behavior

NX should be able to handle the use case as it did before 16.7.0

GitHub Repo

https://github.com/JulioC/nx-examples/tree/bug/16-7-0-plugin

Steps to Reproduce

  1. Clone the linked repository (see recent commits for changes)
  2. Run yarn nx report

Nx Report

Node   : 18.16.0
   OS     : win32-x64
   yarn   : 1.22.19

   nx                 : 16.7.0
   @nx/js             : 16.7.0
   @nx/jest           : 16.7.0
   @nx/linter         : 16.7.0
   @nx/workspace      : 16.7.0
   @nx/angular        : 16.7.0
   @nx/cypress        : 16.7.0
   @nx/devkit         : 16.7.0
   @nx/eslint-plugin  : 16.7.0
   @nx/react          : 16.7.0
   @nrwl/tao          : 16.7.0
   @nx/web            : 16.7.0
   @nx/webpack        : 16.7.0
   nx-cloud           : 16.4.0-beta.1
   typescript         : 5.1.3
   ---------------------------------------
   Community plugins:
   @ngrx/component-store : 16.0.0
   @ngrx/effects         : 16.0.0
   @ngrx/entity          : 16.0.0
   @ngrx/router-store    : 16.0.0
   @ngrx/store           : 16.0.0
   @ngrx/store-devtools  : 16.0.0

Failure Logs

nx run-many -t build --all --skip-nx-cache
Debugger attached.

 >  NX   Cannot set properties of undefined (setting 'name')


   Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.
   If the error persists, please run "nx reset".

Waiting for the debugger to disconnect...
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Operating System

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

Additional Information

It appears this issue was introduced in #18032 when support for multiple projects from plugins was added.

The implementation uses toProjectName utility for generating the unique key for projects. toProjectName assumes the last segment in project root path as the project name.

The issue doesn't depend on the return of CreateNodesFunction in the plugin.

The issue won't happen when the plugin is not declared in nx.json.

This BLOCKS using any plugins after 16.7.0

@JulioC JulioC changed the title Nx 16.7.0 throws on worksapces with plugins when projects have same folder name but different paths Nx 16.7.0 throws in workspaces with plugins when projects have same folder name but different paths Aug 16, 2023
@FrozenPandaz FrozenPandaz added scope: repo scope: core core nx functionality and removed scope: repo labels Aug 16, 2023
@AgentEnder AgentEnder self-assigned this Aug 16, 2023
@github-actions
Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators Sep 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants