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

MultipleProjectsWithSameNameError when .git folder is missing but gitignored dist contains project.json #26567

Closed
2 of 4 tasks
Den-dp opened this issue Jun 15, 2024 · 4 comments
Assignees
Labels

Comments

@Den-dp
Copy link
Contributor

Den-dp commented Jun 15, 2024

Current Behavior

Nx fails to process the project graph when .gitignore'd dist contains project.json, but .git folder is missing.

This situation is common in TeamCity since, by default, it uses VCS checkout mode: Always checkout files on server, which means that there is no .git folder in the working directory. As a workaround, I use VCS checkout mode: Always checkout files on agent, but it is slower.

Expected Behavior

Nx should not fail analyze .gitignore'd files (when there is no .git folder), allowing to run nx commands

GitHub Repo

No response

Steps to Reproduce

# generate empty workspace with nx-dotnet project called my-api
npx create-nx-workspace@latest nx1930 --preset=apps --workspaceType=integrated --ci=skip
cd nx1930
npm i -D @nx-dotnet/core
nx g @nx-dotnet/core:init
nx g @nx-dotnet/core:app my-api --directory=apps --template webapi --test-template nunit --language C# --path-scheme nx

create apps/my-api/project.json with the following content:

{ "name": "my-api", "tags": ["api"]}
# check that build works
nx build my-api

# remove .git folder
mv .git tmp
nx reset

# observe the error
nx show projects --verbose

Nx Report

Node   : 20.12.2
OS     : win32-x64
npm    : 10.8.1

nx (global)    : 19.3.0
nx             : 19.3.0
@nx/js         : 19.3.0
@nx/workspace  : 19.3.0
@nx/devkit     : 19.3.0
@nrwl/tao      : 19.3.0
typescript     : 5.4.5
---------------------------------------
Registered Plugins:
@nx-dotnet/core
---------------------------------------
Community plugins:
@nx-dotnet/core : 2.2.0

Failure Logs

NX   Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it. See errors below.

Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
  MultipleProjectsWithSameNameError: The following projects are defined in multiple locations:
  - my-api:
    - apps/my-api
    - dist/apps/my-api/net7.0

  To fix this, set a unique name for each project in a project.json inside the project's root. If the project does not currently have a project.json, you can create one that contains only a name.
      at validateAndNormalizeProjectRootMap (C:\temp\nx1930\node_modules\nx\src\project-graph\utils\project-configuration-utils.js:446:15)
      at mergeCreateNodesResults (C:\temp\nx1930\node_modules\nx\src\project-graph\utils\project-configuration-utils.js:325:9)
      at C:\temp\nx1930\node_modules\nx\src\project-graph\utils\project-configuration-utils.js:266:85
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async processFilesAndCreateAndSerializeProjectGraph (C:\temp\nx1930\node_modules\nx\src\daemon\server\project-graph-incremental-recomputation.js:148:43)
      at async getCachedSerializedProjectGraphPromise (C:\temp\nx1930\node_modules\nx\src\daemon\server\project-graph-incremental-recomputation.js:46:16)
      at async handleRequestProjectGraph (C:\temp\nx1930\node_modules\nx\src\daemon\server\handle-request-project-graph.js:12:24)
      at async handleResult (C:\temp\nx1930\node_modules\nx\src\daemon\server\server.js:130:16)
      at async handleMessage (C:\temp\nx1930\node_modules\nx\src\daemon\server\server.js:89:9)
      at async C:\temp\nx1930\node_modules\nx\src\daemon\server\server.js:55:9

Package Manager Version

No response

Operating System

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

Additional Information

No response

@acidbubbles
Copy link

I think the issue may also affect git repos where the nx project is not at the root, for example my-repo/nx-root/... worked in 19.2.3 but breaks in 19.3.0. (I can provide additional details if needed)

Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
  MultipleProjectsWithSameNameError: The following projects are defined in multiple locations:
  - my-repo:
    - projects/project1
    - ../unrelated/project1

@FrozenPandaz FrozenPandaz added the scope: core core nx functionality label Jun 24, 2024
@AgentEnder
Copy link
Member

I know this seems unrelated, but the fix is merged to master and in here: #22870

You can try on canary to verify.

@Den-dp
Copy link
Contributor Author

Den-dp commented Jul 26, 2024

@AgentEnder just tried [email protected] and the issue seems fixed.

While trying it, I also encountered an issue with nx reset, but it is already tracked by #27006 and can be worked around via ps node | kill (powershell).

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 Aug 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants