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

outputDirLocalRepo stopps working with newest nx version (19.8.3) #1319

Closed
shanon84 opened this issue Oct 4, 2024 · 17 comments
Closed

outputDirLocalRepo stopps working with newest nx version (19.8.3) #1319

shanon84 opened this issue Oct 4, 2024 · 17 comments

Comments

@shanon84
Copy link

shanon84 commented Oct 4, 2024

Hallo,
after upgrading my dependencies my targets using {option.outputDirLocalRepo} as an output are failing:
`D:\gits\monorepo\node_modules\nx\src\hasher\native-task-hasher-impl.js:32
const plans = this.planner.getPlansReference(tasks.map((t) => t.id), taskGraph);
^

Error: "{options.outputDirLocalRepo}" is an invalid fileset.
All filesets have to start with either {workspaceRoot} or {projectRoot}.
For instance: "!{projectRoot}/**/*.spec.ts" or "{workspaceRoot}/package.json".
If "{options.outputDirLocalRepo}" is a named input, make sure it is defined in nx.json.`

A quickfix seems to be to add
"{options.outputDirLocalRepo}": []
into the namedImports

@khalilou88
Copy link
Owner

Hi @shanon84, I don't think so. The smoke tests using this versions are working fine.
You have an issue in your config, I think you are using an absolute path for options.outputDirLocalRepo. options.outputDirLocalRepo should be a relative path to {workspaceRoot}.

Do you use localRepoRelativePath?

@shanon84
Copy link
Author

shanon84 commented Oct 4, 2024

well, it worked until I upgraded jnxplus and nx to the newest version.
yes, I am using localRepoRelativePath:
"localRepoRelativePath": ".m2/repository"
I asume the outputDirLocalRepo is set by the plugin with localRepoRelativePath + "project groupId+artifactid from pom" automatically?

@khalilou88
Copy link
Owner

Yes you can run nx show project project-name to see it's value.

@khalilou88
Copy link
Owner

I tried to put invalid output but I didn't get same error like you:

  • Target with invalid output:
    "build": {
      "executor": "@jnxplus/nx-maven:run-task",
      "outputs": [
        "{projectRoot}/target",
        "C:\\Users\\khali\\.m2\\repository\\com\\example\\m-sb-lib\\0.0.0-SNAPSHOT",
        "{projectRoot}/.flattened-pom.xml"
      ],
      "options": {
        "task": "install -DskipTests=true"
      }
    },
  • Error:
PS D:\Workspace\Projects\jnxplus-examples> nx build m-sb-lib --skip-nx-cache --verbose

 NX   The following outputs are invalid: 

 - C:\Users\khali\.m2\repository\com\example\m-sb-lib\0.0.0-SNAPSHOT

Run `nx repair` to fix this.
Error: The following outputs are invalid: 
 - C:\Users\khali\.m2\repository\com\example\m-sb-lib\0.0.0-SNAPSHOT

@khalilou88
Copy link
Owner

I need the nx.json and a project.json examples to reproduce this issue.

@shanon84
Copy link
Author

shanon84 commented Oct 4, 2024

here is my repo:
https://github.com/shanon84/monorepo

@khalilou88
Copy link
Owner

@shanon84 I couldn't reproduce it.
Can you clone your project in a new folder, remove "{options.outputDirLocalRepo}": [] and run a fresh npm i or yarn?
Maybe you need just a new node_modules?

@khalilou88
Copy link
Owner

Similar issue here in NX repo: nrwl/nx#27899

@shanon84
Copy link
Author

shanon84 commented Oct 4, 2024

I have deleted node_modules (and caches) and could not reproduce.
Did you run "yarn unittest-BE"? This target has the problem with outputDirLocalRepo, because it is used as an Input.

@khalilou88
Copy link
Owner

@shanon84 I didn't use unittest-BE, I used build-BE.

  • unittest-BE don't work because you use {options.outputDirLocalRepo} as input:
PS D:\Workspace\Projects\monorepo-77> nx unittest-BE my-lib1 --skip-nx-cache --verbose

 NX   Daemon process terminated and closed the connection

Please rerun the command, which will restart the daemon.
If you get this error again, check for any errors in the daemon process logs found in: D:\Workspace\Projects\monorepo-77\.nx\workspace-data\d\daemon.log

Removing {options.outputDirLocalRepo} from inputs make the target works

@khalilou88
Copy link
Owner

Finally, I produce it. I need to disable NX daemon : $env:NX_DAEMON='false'

PS D:\Workspace\Projects\monorepo-77> nx unittest-BE my-lib1 --skip-nx-cache --verbose

 NX   "{options.outputDirLocalRepo}" is an invalid fileset.

All filesets have to start with either {workspaceRoot} or {projectRoot}.
For instance: "!{projectRoot}/**/*.spec.ts" or "{workspaceRoot}/package.json".
If "{options.outputDirLocalRepo}" is a named input, make sure it is defined in nx.json.

Error: "{options.outputDirLocalRepo}" is an invalid fileset.
All filesets have to start with either {workspaceRoot} or {projectRoot}.
For instance: "!{projectRoot}/**/*.spec.ts" or "{workspaceRoot}/package.json".
If "{options.outputDirLocalRepo}" is a named input, make sure it is defined in nx.json.

    at NativeTaskHasherImpl.hashTasks (D:\Workspace\Projects\monorepo-77\node_modules\nx\src\hasher\native-task-hasher-impl.js:32:36)

@khalilou88
Copy link
Owner

If you add {options.outputDirLocalRepo} to outputs it will work because in this case we will calculate the value of outputDirLocalRepo and add it to options object.

We need to look in inputs to make it work in your case, but I don't think it's a valid use case ?

@khalilou88
Copy link
Owner

PR here #1321, but need to think about it more

@shanon84
Copy link
Author

shanon84 commented Oct 4, 2024

Well, my idea behind it was to have it in the cache calculation. I think having the existing project files (pom.xml+src folder) and the previous ones should be enough.

"build-files", "^build-files", "{projectRoot}/target", "{options.outputDirLocalRepo}"
I think I could only use the first two and remove the other two. But I am not certain about the hash calculation. If it is enough to have a correct calculation. Especially with a remotecache in action.

@khalilou88
Copy link
Owner

I am more about throwing an error if options.outputDirLocalRepo is used in inputs: #1322

@khalilou88
Copy link
Owner

khalilou88 commented Oct 4, 2024

I like this idea in your repo

  "namedInputs": {
    "maven": [
      "{projectRoot}/src/**/*",
      "{projectRoot}/pom.xml",
      "{projectRoot}/project.json"
    ],

I suggest naming it defautMaven and add productionMaven for productionMaven you can exclude test files

  "namedInputs": {
    "defaultMaven": [
      "{projectRoot}/src/**/*",
      "{projectRoot}/pom.xml",
      "{projectRoot}/project.json"
    ],
    "productionMaven": [
      "defaultMaven",
      "!{projectRoot}/src/test/**/*"
    ],

But {projectRoot}/target is excluded from git so no problem to keep default values

@shanon84
Copy link
Author

shanon84 commented Oct 4, 2024

I have removed the outpitDirLocalRepo from Inputs. Seems to working still as intended.
Thanks for the suggestion regarding default-/productionMaven. Added it.

@shanon84 shanon84 closed this as completed Oct 4, 2024
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

No branches or pull requests

2 participants