nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.56k stars 2.36k forks source link

project.json task deps build failing now build is broken #28700

Open nhhockeyplayer opened 2 days ago

nhhockeyplayer commented 2 days ago

Current Behavior

SUBJECT: project.json task deps build failing now build is broken

this has run fine for years now its broken after migration

I have 3 published libraries styles, assets, widgets

i created a new one identical to assets (just copies using run:commands) within a dependent task definition inside the build block of project.json

this is for my new library i18n

year or so ago I made a library for assets and now i18n just to process bundle and roll up json files or assets this one for i18n bundles and rolls up i18n json files

so here is my build task inside project.json... see it depends on DEPS to pre-copy the files (the pre-copy is now failing to occur) breaks build

    "targets": {
        "deps": {
            "dependsOn": ["^build"],
            "executor": "@nx/angular:package",
            "outputs": ["{workspaceRoot}/dist/libs/shared/root/i18n"],
            "options": {
                "project": "libs/shared/root/i18n/ng-package.json"

            },
            "configurations": {
                "production": {
                    "tsConfig": "libs/shared/root/i18n/tsconfig.lib.prod.json"
                },
                "development": {
                    "tsConfig": "libs/shared/root/i18n/tsconfig.lib.json"
                }
            },
            "defaultConfiguration": "production"
        },
        "build": {
            "executor": "nx:run-commands",
            "dependsOn": ["deps"],
            "options": {
                "tsConfig": "libs/shared/root/i18n/tsconfig.lib.json",
                "commands": [
                    {
                        "command": "yarn copy-i18n"
                    }
                ]
            }
        },

I found that when I put the task defs back to original (by removing the deps dependency task) I am able to generate output to dist folder for some reason the yarn copy-i18n package.json script within the deps task def refuses to execute now after migration nothing has changed ???

Expected Behavior

library WAS building into dist fine

now it does nothing and builds nothing into dist folder

library should be built into dist folder by standard

GitHub Repo

https://github.com/nhhockeyplayer/meanstacknh

please checkout latest in #main

Steps to Reproduce

just execute the following command from root folder of repo

source .clean.zsh

and it will yarn install, build everything and then build the library in question shared-root-i18n

Nx Report

nx report

NX Report complete - copy this into the issue template

Node : 22.9.0 OS : darwin-x64 Native Target : x86_64-macos npm : 10.9.0

nx (global) : 20.0.0 nx : 20.0.6 @nx/js : 20.0.6 @nx/jest : 20.0.6 @nx/eslint : 20.0.6 @nx/workspace : 20.0.6 @nx/angular : 20.0.6 @nx/cypress : 20.0.6 @nx/devkit : 20.0.6 @nx/esbuild : 20.0.6 @nx/eslint-plugin : 20.0.6 @nx/express : 20.0.6 @nx/nest : 20.0.6 @nx/node : 20.0.6 @nx/web : 20.0.6 @nx/webpack : 20.0.6 nx-cloud : 19.1.0 typescript : 5.5.4

Registered Plugins: @nx/cypress/plugin @nx/eslint/plugin

Community plugins: @compodoc/compodoc : 1.1.26 @fortawesome/angular-fontawesome : 0.15.0 @ionic/angular : 6.7.5 @jsverse/transloco : 7.5.0 @ngrx/component : 18.0.2 @ngrx/component-store : 18.0.2 @ngrx/effects : 18.0.2 @ngrx/entity : 18.0.2 @ngrx/operators : 18.0.2 @ngrx/router-store : 18.0.2 @ngrx/schematics : 18.0.2 @ngrx/store : 18.0.2 @ngrx/store-devtools : 18.0.2 angular-builder-custom-terser-options : 1.0.1 apollo-angular : 7.2.1

Failure Logs

nx build shared-root-i18n --verbose [NX CLOUD] Using light client [NX CLOUD] A local bundle currently exists: { version: '2410.25.5.hotfix1', fullPath: '/Users/meanstack02/meanstacknh/node_modules/.cache/nx/cloud/2410.25.5.hotfix1' } [NX CLOUD] Last verification was more than 30 minutes ago, verifying bundle is still valid [NX CLOUD] Currently installed bundle is invalid, downloading version 2410.25.5.hotfix1 from https://cloud.nx.app/nx-cloud/static/client-bundle [NX CLOUD] Using bundle path: { version: '2410.25.5.hotfix1', fullPath: '/Users/meanstack02/meanstacknh/node_modules/.cache/nx/cloud/2410.25.5.hotfix1' } Was not able to require.resolve module nx/src/utils/app-root from the following paths: /Users/meanstack02/meanstacknh/node_modules/nx-cloud/node_modules,/Users/meanstack02/meanstacknh/node_modules. This may be expected. Was not able to require.resolve module nx/src/utils/app-root from the following paths: /Users/meanstack02/meanstacknh/node_modules/nx-cloud/node_modules,/Users/meanstack02/meanstacknh/node_modules. This may be expected.

NX Running target build for project shared-root-i18n and 10 tasks it depends on:

———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— [Nx Cloud Debug] Attempting to acquire filesystem lock with path: /var/folders/73/pgw9tfdj5fz826zd6cc4p0vr0000gn/T/client-instance-id.lock [Nx Cloud Debug] Failed to create folder lock at path: /var/folders/73/pgw9tfdj5fz826zd6cc4p0vr0000gn/T/client-instance-id.lock [Nx Cloud] Unable to detect a VCS context from the environment.

NX RunStart

{ "meta": {}, "branch": null, "runGroup": "ad5aa1ab49d081874a77d765e2c99db02399c86a", "ciExecutionId": null, "ciExecutionEnv": "", "hashes": [ "3439582441627692645", "5175769339728590183", "14002918542955276370", "6091270245342170068", "6395607724888593115" ], "machineInfo": { "machineId": "uHiOzR0l5SEx0kjZqAemHQ==", "platform": "darwin", "version": "Darwin Kernel Version 21.6.0: Mon Jun 24 00:56:10 PDT 2024; root:xnu-8020.240.18.709.2~1/RELEASE_X86_64", "cpuCores": 8 }, "vcsContext": null, "clientInstanceSource": "CLOUD_RUNNER", "clientInstanceId": "5a35aa58-c684-456f-a8cb-c1630afe7c06" }

nx run shared-root-ui-assets:deps:production [local cache]

Building Angular Package


Building entry point '@nhhockeyplayer/shared-root-ui-assets'


Built Angular Package

Build at: 2024-10-30T14:43:16.594Z - Time: 1148ms

nx run shared-util-isomorphic:build:production [existing outputs match the cache, left as is]

Building Angular Package


Building entry point '@nhhockeyplayer/shared-util-isomorphic'


Built Angular Package

Build at: 2024-10-30T14:43:17.185Z - Time: 1730ms

nx run shared-util-models:build:production [existing outputs match the cache, left as is]

Building Angular Package


Building entry point '@nhhockeyplayer/shared-util-models'


Built Angular Package

Build at: 2024-10-30T14:43:20.502Z - Time: 2066ms

RunStart duration: 126

nx run shared-root-ui-assets:build

yarn copy-assets --tsConfig=libs/shared/root/ui-assets/tsconfig.lib.json

yarn run v1.22.22 $ cp -R dist/libs/shared/root/ui-assets/src/lib/assets dist/libs/shared/root/ui-assets && npm run clean-assets --tsConfig=libs/shared/root/ui-assets/tsconfig.lib.json

@nhhockeyplayer/meanstacknh@0.0.0 clean-assets rm -rf dist/libs/shared/root/ui-assets/src

Done in 0.46s.

nx run shared-root-ui-styles:deps

cd ../../../.. --tsConfig=libs/shared/root/ui-styles/tsconfig.lib.json

nx build shared-root-ui-assets --tsConfig=libs/shared/root/ui-styles/tsconfig.lib.json

[NX CLOUD] Using light client [NX CLOUD] A local bundle currently exists: { version: '2410.25.5.hotfix1', fullPath: '/Users/meanstack02/meanstacknh/node_modules/.cache/nx/cloud/2410.25.5.hotfix1' } [NX CLOUD] Last verification was within the past 30 minutes, will not verify this time [NX CLOUD] Using bundle path: { version: '2410.25.5.hotfix1', fullPath: '/Users/meanstack02/meanstacknh/node_modules/.cache/nx/cloud/2410.25.5.hotfix1' } Was not able to require.resolve module nx/src/utils/app-root from the following paths: /Users/meanstack02/meanstacknh/node_modules/nx-cloud/node_modules,/Users/meanstack02/meanstacknh/node_modules. This may be expected. Was not able to require.resolve module nx/src/utils/app-root from the following paths: /Users/meanstack02/meanstacknh/node_modules/nx-cloud/node_modules,/Users/meanstack02/meanstacknh/node_modules. This may be expected.

NX Running target build for project shared-root-ui-assets and 1 task it depends on:

[Nx Cloud Debug] Attempting to acquire filesystem lock with path: /var/folders/73/pgw9tfdj5fz826zd6cc4p0vr0000gn/T/client-instance-id.lock [Nx Cloud Debug] Failed to create folder lock at path: /var/folders/73/pgw9tfdj5fz826zd6cc4p0vr0000gn/T/client-instance-id.lock [Nx Cloud] Unable to detect a VCS context from the environment.

NX RunStart

{ "meta": {}, "branch": null, "runGroup": "ad5aa1ab49d081874a77d765e2c99db02399c86a", "ciExecutionId": null, "ciExecutionEnv": "", "hashes": [ "17048741841493738582" ], "machineInfo": { "machineId": "uHiOzR0l5SEx0kjZqAemHQ==", "platform": "darwin", "version": "Darwin Kernel Version 21.6.0: Mon Jun 24 00:56:10 PDT 2024; root:xnu-8020.240.18.709.2~1/RELEASE_X86_64", "cpuCores": 8 }, "vcsContext": null, "clientInstanceSource": "CLOUD_RUNNER", "clientInstanceId": "5a35aa58-c684-456f-a8cb-c1630afe7c06" }

nx run shared-root-ui-assets:deps:production [local cache]

Building Angular Package


Building entry point '@nhhockeyplayer/shared-root-ui-assets'


Built Angular Package

Build at: 2024-10-30T14:43:16.594Z - Time: 1148ms

nx run shared-root-ui-assets:build --tsConfig=libs/shared/root/ui-styles/tsconfig.lib.json

yarn copy-assets --tsConfig=libs/shared/root/ui-styles/tsconfig.lib.json

RunStart duration: 131 yarn run v1.22.22 $ cp -R dist/libs/shared/root/ui-assets/src/lib/assets dist/libs/shared/root/ui-assets && npm run clean-assets --tsConfig=libs/shared/root/ui-styles/tsconfig.lib.json

@nhhockeyplayer/meanstacknh@0.0.0 clean-assets rm -rf dist/libs/shared/root/ui-assets/src

Done in 0.38s.

NX Successfully ran target build for project shared-root-ui-assets and 1 task it depends on

Nx read the output from the cache instead of running the command for 1 out of 2 tasks.

NX Storing terminal outputs for shared-root-ui-assets:build with hash 17048741841493738582

cd libs/shared/root/ui-styles --tsConfig=libs/shared/root/ui-styles/tsconfig.lib.json

nx run shared-root-ui-styles:compile:production [local cache]

Building Angular Package


Building entry point '@nhhockeyplayer/shared-root-ui-styles'


Built Angular Package

Build at: 2024-10-30T14:43:21.838Z - Time: 1005ms

nx run shared-root-ui-styles:build

yarn copy-styles --tsConfig=libs/shared/root/ui-styles/tsconfig.lib.json

yarn run v1.22.22 $ cp -R dist/libs/shared/root/ui-styles/src/lib/* dist/libs/shared/root/ui-styles && npm run clean-styles --tsConfig=libs/shared/root/ui-styles/tsconfig.lib.json

@nhhockeyplayer/meanstacknh@0.0.0 clean-styles rm -rf dist/libs/shared/root/ui-styles/src

Done in 0.40s.

nx run shared-util-utility:build:production [existing outputs match the cache, left as is]

Building Angular Package


Building entry point '@nhhockeyplayer/shared-util-utility'


Built Angular Package

Build at: 2024-10-30T14:43:24.970Z - Time: 1258ms

nx run shared-root-environment:build:production [existing outputs match the cache, left as is]

Building Angular Package


Building entry point '@nhhockeyplayer/shared-root-environment'


Built Angular Package

Build at: 2024-10-30T14:43:27.603Z - Time: 1487ms

NX Nx Cloud: Cache miss 5175769339728590183.

nx run shared-root-i18n:deps:production

It looks like all of shared-root-i18n's dependencies have not been built yet:

You might be missing a "targetDefaults" configuration in your root nx.json (https://nx.dev/reference/project-configuration#target-defaults), or "dependsOn" configured in shared-root-i18n's project.json (https://nx.dev/reference/project-configuration#dependson)

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

NX Running target build for project shared-root-i18n and 10 tasks it depends on failed

Failed tasks:

Hint: run the command with --verbose for more details.

NX Storing terminal outputs for shared-root-ui-assets:build with hash 6395607724888593115

NX Storing terminal outputs for shared-root-ui-styles:deps with hash 6091270245342170068

NX Storing terminal outputs for shared-root-ui-styles:build with hash 14002918542955276370

NX Storing terminal outputs for shared-root-i18n:deps:production with hash 5175769339728590183

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

Package Manager Version

npm --version 10.9.0

Operating System

Additional Information

be nice to see my build working I have a ton of other issues cant get into business logic & coding pre-empted with all the build efrastructure issues

Im happy yo provide access to repo colum already has access to it

help

nhhockeyplayer commented 2 days ago

more log failure shown at nxcloud see attached the copy command is failing as noted within the DEPS build task defImage

nhhockeyplayer commented 2 days ago

this is the runtime build command message output

and I cannot make sense of what the solution is

It looks like all of shared-root-i18n's dependencies have not been built yet:
- shared-root-ui-styles

You might be missing a "targetDefaults" configuration in your root nx.json (https://nx.dev/reference/project-configuration#target-defaults),
or "dependsOn" configured in shared-root-i18n's project.json (https://nx.dev/reference/project-configuration#dependson)

why would it work find 2 days ago and today its not working

im going to reboot the machine because this one is spooky

nhhockeyplayer commented 2 days ago

still blue in the face

cant get nx to run a post build copy

somehow the pre-build copy started to fail

here is code if anyone wants to model it correctly

after running build no i18n json files land in the dist folder where they are suppose to at the root of the lib

    "targets": {
        "build": {
            "dependsOn": [
                {
                    "dependencies": true,
                    "target": "deps"
                }
            ],
            "executor": "@nx/angular:package",
            "outputs": ["{workspaceRoot}/dist/libs/shared/root/i18n"],
            "options": {
                "project": "libs/shared/root/i18n/ng-package.json"

            },
            "configurations": {
                "production": {
                    "tsConfig": "libs/shared/root/i18n/tsconfig.lib.prod.json"
                },
                "development": {
                    "tsConfig": "libs/shared/root/i18n/tsconfig.lib.json"
                }
            },
            "defaultConfiguration": "production"
        },
        "deps": {
            "executor": "nx:run-commands",
            "dependsOn": ["copy-assets"],
            "options": {
                "tsConfig": "libs/shared/root/i18n/tsconfig.lib.json",
                "commands": [
                    {
                        "command": "npm run copy-i18n"
                    }
                ]
            }
        },
nhhockeyplayer commented 2 days ago

can someone explain why this wont work?

    "targets": {
        "build": {
            "dependsOn": [
                {
                    "dependencies": true,
                    "target": "copy-i18n-assets"
                }
            ],
            "executor": "@nx/angular:package",
            "outputs": ["{workspaceRoot}/dist/libs/shared/root/i18n"],
            "options": {
                "project": "libs/shared/root/i18n/ng-package.json"

            },
            "configurations": {
                "production": {
                    "tsConfig": "libs/shared/root/i18n/tsconfig.lib.prod.json"
                },
                "development": {
                    "tsConfig": "libs/shared/root/i18n/tsconfig.lib.json"
                }
            },
            "defaultConfiguration": "production"
        },
        "copy-i18n-assets": {
            "executor": "nx:run-commands",
            "options": {
                "tsConfig": "libs/shared/root/i18n/tsconfig.lib.json",
                "commands": [
                    {
                        "command": "npm run copy-i18n"
                    }
                ],
                "parallel": false
            }
        },
nhhockeyplayer commented 2 days ago

this is about as simple as it gets I read all the docs alot of examples but nothing with continuity like pre-build script or post-build-script.... this is all Im doing

can someone take a moment and explain NX here

I bugged this because my model was working yesterday now its failing after a migration. Nx.json did not take any hits.

thanks


    "targets": {
        "deps": {
            "executor": "nx:run-commands",
            "options": {
                "tsConfig": "libs/shared/root/i18n/tsconfig.lib.json",
                "commands": [
                    {
                        "command": "npm run copy-i18n"
                    }
                ]
            }
        },
        "build": {
            "dependsOn": ["^build", "^deps"],
            "executor": "@nx/angular:package",
            "outputs": ["{workspaceRoot}/dist/libs/shared/root/i18n"],
            "options": {
                "project": "libs/shared/root/i18n/ng-package.json"
            },
            "configurations": {
                "production": {
                    "tsConfig": "libs/shared/root/i18n/tsconfig.lib.prod.json"
                },
                "development": {
                    "tsConfig": "libs/shared/root/i18n/tsconfig.lib.json"
                }
            },
            "defaultConfiguration": "production"
        },
nhhockeyplayer commented 2 days ago

well I have determined my code is alright but something is wrong

1st run when populating dist folder it does not work 2nd run it works

why?

the copy fails due to non-existent directories on 1st run

that means no bug NX does what it suppose to; this is a limitation on terminal commands

what NX could fix is how to model these in such a sequence that this trivial issue can occur and it cant... thats the bug

so I challenge anyone to get this block running 1st time run

the million dollar question after poerusing all the docs on task defs and targets how do we contiguously chronologically sequence 2 or 3 targets in chronological synchronous order? no example of this exists and my attempts fail even tried the rsync terminal shell command but thats all out of context hack

    "targets": {
        "build": {
            "dependsOn": ["deviant-stupid-substandard-out-of-context-copy-that-occurs-on-2nd-run"],
            "executor": "@nx/angular:package",
            "outputs": ["{workspaceRoot}/dist/libs/shared/root/i18n"],
            "options": {
                "project": "libs/shared/root/i18n/ng-package.json"

            },
            "configurations": {
                "production": {
                    "tsConfig": "libs/shared/root/i18n/tsconfig.lib.prod.json"
                },
                "development": {
                    "tsConfig": "libs/shared/root/i18n/tsconfig.lib.json"
                }
            },
            "defaultConfiguration": "production"
        },
        "deviant-stupid-substandard-out-of-context-copy-that-occurs-on-2nd-run": {
            "executor": "nx:run-commands",
            "options": {
                "commands": [
                    {
                        "command": "npm run copy-i18n"
                    }
                ]
            }
        },