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

Multiple plugin issues #23

Open
jcbdev opened this issue Jun 30, 2023 · 11 comments · Fixed by nrwl/nx#17949
Open

Multiple plugin issues #23

jcbdev opened this issue Jun 30, 2023 · 11 comments · Fixed by nrwl/nx#17949

Comments

@jcbdev
Copy link

jcbdev commented Jun 30, 2023

I have been evaluating both this and the @nxrs/cargo plugins and I liked the idea of this because of the integration with napi out of the box.

Unfortunately whereas I can get the other lib to work quite seamlessly I am struggling in multiple ways with this one.

For a start if I try to integrate into an existing repository then I can create a new library, but no nx build/test/lint/graph command will work for ANY project (including the non-rust based ones in the project before the addition).

I have found that if I comment out the following in the nx.json then the builds start to work again but this seems like the wrong thing to do

{
...
    // "plugins": ["@monodon/rust"],
...
}

Otherwise each command fails instantly like so:

 >  NX   Daemon process terminated and closed the connection

   Please rerun the command, which will restart the daemon.

Alternatively I tried a completely fresh project like so:

npx create-nx-workspace --preset=@monodon/rust
nx generate @monodon/rust:library my-rust-node-lib --napi

but trying to run project specific commands from the monorepo root fail with the error

> nx run my_rust_node_lib:build

Type Error: No package.name field in Cargo.toml

you HAVE to change the current directly to the libs/my_rust_node_lib for the command to work which is not how any other NX command normally works.

@Cammisuli
Copy link
Owner

Well that's not right. We use this plugin for the main nx repo, so it should be working.

What's the version of your nx workspace? Or is there some kind of reproduction I can see?

@jcbdev
Copy link
Author

jcbdev commented Jun 30, 2023

I have the latest nx installed v16.4 (for both the cli for the new nx monorepo and in the monorepo I tried to add to)

MacOSX m1, node v18.12

@jcbdev
Copy link
Author

jcbdev commented Jun 30, 2023

I just realised the fresh version was on v14 by default on the generator. If I run this I and upgrade the default generator project to nx v16 then none of the builds work at all

npx create-nx-workspace --preset=@monodon/rust
nx generate @monodon/rust:library my-rust-node-lib --napi
nx migrate latest
yarn
nx migrate latest

Then if I run nx build my_rust_node_lib i get the following error:

 >  NX   Failed to process the project graph with "nx-js-graph-plugin".

   Source project does not exist: 

@Cammisuli
Copy link
Owner

I couldn't see your original issue, but I did notice some things with the dependencies not matching. Can you give it a shot again with @monodon/[email protected]?

@jcbdev
Copy link
Author

jcbdev commented Jun 30, 2023

No same issue unfortunately (for both scenarios - mixed existing repo saying daemon was terminated and new repo with just rust saying "Failed to process the project graph with "nx-js-graph-plugin").

Here is the repro of the 2nd scenario (clean rust only, upgraded to latest nx and using your latest 1.2.0) - https://github.com/jcbdev/monodon-plugin-issue-repro

If you need anything else let me know.

@jcbdev
Copy link
Author

jcbdev commented Jun 30, 2023

Actually. I just killed the node_modules/yarn.lock after upgrading the library to 1.2.0 as you suggested and reinstalled all of the packages from scratch and the rust only clean repo works 🤔

I tried on the other project (existing & mixed js/rust) and see if it's some dependency issue but it still crashes in the same way with the plugin enabled.

@Cammisuli
Copy link
Owner

Yea. The nx-js-graph-plugin is part of nx core.

There's an issue with it related with project roots having a ".", and comparing it with a blank "".

I'm gonna fix it in the nx repo.

@Cammisuli
Copy link
Owner

hey @jcbdev, can you give it a shot again with Nx 16.5.0?

@abbudao
Copy link

abbudao commented Sep 5, 2023

I had the same problem; pretty hard to track down precisely what is causing it. The behavior on my end is that randomly it simply stopped working between commits. It's probably something related to breaking changes on Nx internals and the version used.
It seems they are deprecating the ProjectGraphBuilder, and they have made some non-intentional breaking changes?

Checking daemon.log yields:

[NX Daemon Server] - 2023-09-04T22:34:38.976Z - Error detected when creating a project graph: Failed to process the project graph with "@monodon/rust".
Source project pricing-service-v2 does not have a file: apps/pricing-service-v2/Cargo.toml
[NX Daemon Server] - 2023-09-04T22:34:38.976Z - [REQUEST]: Responding to the client with an error. Error when preparing serialized project graph. Failed to process the project graph with "@monodon/rust".
Source project pricing-service-v2 does not have a file: apps/pricing-service-v2/Cargo.toml
Error: Failed to process the project graph with "@monodon/rust".
Source project pricing-service-v2 does not have a file: apps/pricing-service-v2/Cargo.toml
    at ProjectGraphBuilder.addDependency (/home/abbud/Documents/securities/node_modules/@monodon/rust/node_modules/nx/src/project-graph/project-graph-builder.js:197:23)
    at ProjectGraphBuilder.addStaticDependency (/home/abbud/Documents/securities/node_modules/@monodon/rust/node_modules/nx/src/project-graph/project-graph-builder.js:80:14)
    at addExplicitDependency (/home/abbud/Documents/securities/packages/rust/src/graph.ts:79:11)
    at Object.processProjectGraph (/home/abbud/Documents/securities/packages/rust/src/graph.ts:52:11)
    at /home/abbud/Documents/securities/node_modules/nx/src/project-graph/build-project-graph.js:138:42
    at Generator.next (<anonymous>)
    at fulfilled (/home/abbud/Documents/securities/node_modules/tslib/tslib.js:166:62)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[NX Daemon Server] - 2023-09-04T22:34:38.979Z - Done responding to the client null

Debugging the plugin behavior, I could find that the fileMap is not being generated correctly on the constructor of ProjectGraphBuilder, getProjectFileMap yields { projectFileMap: {}, allWorkspaceFiles: [] }. I can make the plugin work again by constructing the fileMap using createProjectFileMapUsingProjectGraph and passing it to the ProjectGraphBuilder.

I will go ahead and create a Pull Request with this fix.

@Cammisuli
Copy link
Owner

v1.3.2 should be using the new nx apis, so give it a shot and let me know. Thanks!

@abbudao
Copy link

abbudao commented Nov 30, 2023

I upgraded and had no issues so far. Everything seems to be working great! 🎉

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