Bug 10337

Summary: devtool: fails to add an npm project if nodejs-native is not already built
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Henry Bruce <henry.bruce>
Component: devtools / tool chainAssignee: Paul Eggleton <bluelightning>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: brian.avery, meta.mr.watcher, meta.watcher
Version: 2.2   
Target Milestone: 2.2 M4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Henry Bruce 2016-09-27 22:12:02 UTC
Observed behavior
-----------------
$ devtool add "npm://registry.npmjs.org;name=grunt-cli;version=1.1.0"
ERROR: Command 'recipetool --color=always create -o /tmp/devtooll09swkt2 "npm://registry.npmjs.org;name=grunt-cli;version=1.1.0"  -x /path/to/build/workspace/sources/devtoolsrcuogngddz' failed:
ERROR: npm:// URL requested but npm is not available - you need to either build nodejs-native or install npm using your package manager

If you run 'bitbake nodejs-native' *OR* install node on host system, then rerun above devtool add command it complete OK.

Observed behavior
-----------------
[build]$ devtool add "npm://registry.npmjs.org;name=grunt-cli;version=1.1.0"
Command completes without error and does not require nodejs-native to be man ually build aHEAD OF TIME.

Notes
------
1. This is a regression. The above 'devtool add' command works on krogoth.
2. nodejs-native recipe should not allow fallback to node installed on host
Comment 1 Paul Eggleton 2016-09-28 19:36:37 UTC
1. devtool add did require npm on krogoth - there's no way it could fetch the source for the specified npm package without it. It may be that we check for it now where we didn't before. I'll have to investigate. Do you have npm available on your host?

2. Not sure I understand what you mean - should *not* allow ?

If devtool attempted to build nodejs-native if it could not run npm, would that be OK?
Comment 2 Stephen K Jolley 2016-09-29 14:46:38 UTC
Henry - please comment
Comment 3 brian avery 2016-09-29 14:48:47 UTC
yes.  I believe so.  It seems like we should either:
1) document that to use the node functionality you need to have host npm
or
2) (better, i think) just try to build nodejs-native if not available.

When I had no host npm and had built nodejs-native, it worked.
Comment 4 Henry Bruce 2016-09-29 17:28:11 UTC
To extend on my original comments

1. To clarify observed behavior on krogoth
When running devtool add "npm://registry.npmjs.org;name=grunt-cli;version=1.1.0" 
'devtool add' fetches and builds nodejs-native then completes successfully
'devtool build grunt-cli' will then complete successfully

2. On master the observed behavior (i.e. failure) can be avoided if npm is installed on host. We should update devtool's npm support to avoid using host's npm as its version is not controlled and force use of npm from nodejs-native. Thus if nodejs-native is not available, 'devtool add' of npm project should fail.

I hope that makes more sense.