← Back to issue list

nodejs plugin: build fails if there are missing peer dependencies.

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1819804
Type
issue
State
open
Author
~thebitlink
Labels
Created
Updated
Closed

Current evaluation

Snapcraft nodejs plugin build fails when npm ls --json exits non-zero on missing peer deps; the CalledProcessError fallback is dead code since run_output wraps it in SnapcraftPluginCommandError. Open 7.5 years, unlabelled, no maintainer activity.

Suggested action: needs triage

Reason: The issue has no labels, zero comments, and no maintainer response in 7.5 years, showing no sign of ever being triaged or categorised. It is a well-diagnosed real bug (the reporter correctly identifies that run_output converts CalledProcessError into SnapcraftPluginCommandError, making the existing try/except fallback dead code), so it should not be closed as stale without first confirming whether the code path still exists in the current nodejs plugin. I could not verify the current code state (no pinned SHA available for the snapcraft repo), which limits confidence.

Impact: 45 Quick Win: 31.5 Staleness: 95 Complexity: 30 Confidence: 65 Support Request: 0

Issue body

This happens when trying to run `npm ls --json` at the build stage. If there are any missing peer dependencies, the command exits with a non-zero exit code. However, most of the time those errors can be safely ignored. An attempt to mitigate this is already in place: ``` def _get_installed_node_packages(self, cwd): # There is no yarn ls cmd = [os.path.join(self._npm_dir, "bin", "npm"), "ls", "--json"] try: output = self.run_output(cmd, cwd) except subprocess.CalledProcessError as error: # XXX When dependencies have missing dependencies, an error like # this is printed to stderr: # npm ERR! peer dep missing: glob@*, required by glob-promise@3.1.0 # retcode is not 0, which raises an exception. output = error.output.decode(sys.getfilesystemencoding()).strip() ``` However, `run_output()` itself captures the `CalledProcessError`, rasing a different type of exception (SnapcraftPluginCommandError): ``` def run_output(self, cmd, cwd=None, **kwargs): if not cwd: cwd = self.builddir os.makedirs(cwd, exist_ok=True) try: return common.run_output(cmd, cwd=cwd, **kwargs) except CalledProcessError as process_error: raise errors.SnapcraftPluginCommandError( command=cmd, part_name=self.name, exit_code=process_error.returncode ) from process_error ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 45
Quick Win: 31.5
Staleness: 95
Complexity: 30
Confidence: 65
Support Request: 0
needs triage Snapcraft nodejs plugin build fails when npm ls --json exits non-zero on missing peer deps; the CalledProcessError fallback is dead code since run_output wraps it in SnapcraftPluginCommandError. Open 7.5 years, unlabelled, no maintainer activity.
qwen/qwen3.6-35b-a3b
Staleness: 98
Complexity: 35
Confidence: 90
Support Request: 5
close stale Nodejs plugin build fails when npm ls --json encounters missing peer dependencies. The run_output wrapper catches and re-raises the exception, bypassing the intended fallback logic. The issue is over 7 years old with no maintainer engagement.
qwen/qwen3.6-35b-a3b
Staleness: 100
Complexity: 40
Confidence: 90
Support Request: 10
close stale Nodejs plugin build fails due to missing peer dependencies causing npm ls to exit non-zero. Issue is 7+ years old with no activity or maintainer response.
qwen3.6-35b-a3b-mtp-q6
Staleness: 95
Complexity: 20
Confidence: 85
Support Request: 5
needs triage Nodejs plugin build fails during npm ls due to missing peer dependencies triggering an unhandled exception. Issue remains untriaged and inactive for over seven years.
qwen3.6-35b-a3b-mtp-q6
Staleness: 98
Complexity: 30
Confidence: 70
Support Request: 5
close stale Node.js plugin build fails on missing peer dependencies due to incorrect exception handling in npm ls output capture. The report is over 7 years old with zero maintainer interaction or labels.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#1886858 nodejs plugin doesn't set npm path for custom node version snapcraft (launchpad) open Bug: snapcraft's nodejs plugin downloads a custom nodejs-version but still runs build commands with the default node, leaving npm out of PATH. Reporter supplied a PATH workaround. 6 years old, no labels, zero comments, no maintainer response; nodejs plugin since deprecated/removed.
74%
#2424 nodejs plugin: fail gracefully when a package.json is missing snapcraft merged Merged into master. The nodejs plugin now fails gracefully when package.json is missing, resolving LP #1807971 and SNAPCRAFT-9X. The change adds 40 lines and removes 8 across two files, achieving 100% diff coverage.
73%
#1731003 node app builds forked, but not referencing upstream source snapcraft (launchpad) open Snapcraft 2.34 node plugin fails to build when source is a remote URL (rimraf not found, node_modules missing) while a local checkout builds fine. 8.8 years old, zero maintainer interaction; the 2.x node plugin has since been rewritten in snapcraft 8.x.
72%
#1871273 Can't Buidl on WSL2 any Longer snapcraft (launchpad) open Snapcraft build fails on WSL2 with KeyError 'dependencies' in the nodejs plugin's _get_installed_node_packages while parsing yarn output. 6+ years old, zero comments, no maintainer response; old plugin architecture since replaced.
72%
#1660614 snapcraft's nodejs plugin does not refresh the global, user cache before installing dependencies snapcraft (launchpad) open Legacy snapcraft nodejs plugin used npm --cache-min=Infinity, so a stale npm cache could cause ETARGET build failures when a dependency version was newly published. No maintainer response in ~9.5 years; the legacy plugin no longer exists in current snapcraft.
72%