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

Modified files after build cause subsequent build to fail #241

Closed
wborn opened this issue May 2, 2020 · 4 comments
Closed

Modified files after build cause subsequent build to fail #241

wborn opened this issue May 2, 2020 · 4 comments
Labels
basic ui Basic UI

Comments

@wborn
Copy link
Member

wborn commented May 2, 2020

After running mvn clean install the following files are reported as modified by git status:

	modified:   bundles/org.openhab.ui.basic/npm-shrinkwrap.json
	modified:   bundles/org.openhab.ui.habot/web/package-lock.json
	modified:   bundles/org.openhab.ui/web/package-lock.json

When you then start another build with these modified files, the org.openhab.ui.basic bundle fails to build:

[INFO] --- frontend-maven-plugin:1.9.0:npm (gulp build) @ org.openhab.ui.basic ---
[INFO] Running 'npm run build' in /home/wouter/git/openhab/openhab-webui/bundles/org.openhab.ui.basic
[INFO] 
[INFO] > [email protected] build /home/wouter/git/openhab/openhab-webui/bundles/org.openhab.ui.basic
[INFO] > gulp default
[INFO] 
[INFO] fs.js:35
[INFO] } = primordials;
[INFO]     ^
[INFO] 
[INFO] ReferenceError: primordials is not defined
[INFO]     at fs.js:35:5
[INFO]     at req_ (/home/wouter/git/openhab/openhab-webui/bundles/org.openhab.ui.basic/node_modules/natives/index.js:143:24)
[INFO]     at Object.req [as require] (/home/wouter/git/openhab/openhab-webui/bundles/org.openhab.ui.basic/node_modules/natives/index.js:55:10)
[INFO]     at Object.<anonymous> (/home/wouter/git/openhab/openhab-webui/bundles/org.openhab.ui.basic/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:1:37)
[INFO]     at Module._compile (internal/modules/cjs/loader.js:1158:30)
[INFO]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
[INFO]     at Module.load (internal/modules/cjs/loader.js:1002:32)
[INFO]     at Function.Module._load (internal/modules/cjs/loader.js:901:14)
[INFO]     at Module.require (internal/modules/cjs/loader.js:1044:19)
[INFO]     at require (internal/modules/cjs/helpers.js:77:18)
[INFO] npm ERR! code ELIFECYCLE
[INFO] npm ERR! errno 1
[INFO] npm ERR! [email protected] build: `gulp default`
[INFO] npm ERR! Exit status 1
[INFO] npm ERR! 
[INFO] npm ERR! Failed at the [email protected] build script.
[INFO] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Reverting the changes in bundles/org.openhab.ui.basic/npm-shrinkwrap.json seems to fix it.

@ghys
Copy link
Member

ghys commented May 2, 2020

I created the npm-shrinkwrap.json file to fix the above error as explained here: https://stackoverflow.com/a/58394828

It's the "If your project isn't actively being worked on and you use npm" alternative because it's simpler but indeed:

Unfortunately, this solution does not work anymore if you npm install again.

It isn't a big problem with build servers but can become problematic when you try to build a local fork multiple times. The "If your project is in active development and you use npm" solution might be better & worth a try.

@wborn
Copy link
Member Author

wborn commented May 2, 2020

Thanks for the info! I gave it a try but it looks like the frontend-maven-plugin doesn't configure anything for npx to work:

[INFO] --- frontend-maven-plugin:1.9.0:npm (npm install) @ org.openhab.ui.basic ---
[INFO] Running 'npm install' in /home/wouter/git/openhab/openhab-webui/bundles/org.openhab.ui.basic
[INFO] 
[INFO] > [email protected] preinstall /home/wouter/git/openhab/openhab-webui/bundles/org.openhab.ui.basic
[INFO] > npx npm-force-resolutions
[INFO] 
[INFO] sh: 1: npx: not found
[INFO] npm ERR! code ELIFECYCLE
[INFO] npm ERR! syscall spawn
[INFO] npm ERR! file sh
[INFO] npm ERR! errno ENOENT
[INFO] npm ERR! [email protected] preinstall: `npx npm-force-resolutions`
[INFO] npm ERR! spawn ENOENT
[INFO] npm ERR! 
[INFO] npm ERR! Failed at the [email protected] preinstall script.
[INFO] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@ghys
Copy link
Member

ghys commented May 2, 2020

Great, thank you for trying!
I believe npx npm-force-resolutions is basically a shortcut for node_modules/.bin/npm-force-resolutions (at least in this case) so maybe using that directly in the preinstall hook will work?

@ghys
Copy link
Member

ghys commented May 2, 2020

Hm, disregard, it probably won't work since the npm-force-resolutions won't be installed...

@ghys ghys added the basic ui Basic UI label Jul 23, 2020
rogierhofboer added a commit to rogierhofboer/openhab-webui that referenced this issue Jun 22, 2021
@ghys ghys closed this as completed in f3fe725 Aug 25, 2021
wborn added a commit to wborn/openhab-webui that referenced this issue Aug 31, 2021
wborn added a commit to wborn/openhab-webui that referenced this issue Aug 31, 2021
kaikreuzer pushed a commit that referenced this issue Sep 18, 2021
kaikreuzer pushed a commit that referenced this issue Dec 12, 2021
kaikreuzer pushed a commit that referenced this issue Oct 24, 2024
* Use Maven 3.9.9
* Use Ubuntu 24.04
* Verify there are no changed files

This will help preventing issues like:

* #20
* #107
* #241
* #2814

Signed-off-by: Wouter Born <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
basic ui Basic UI
Projects
None yet
Development

No branches or pull requests

2 participants