depends on incompatible version of commander

Bug #2003697 reported by Aaron B. Russell
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
node-yarnpkg (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Issue affects Jammy with nodepkg 1.22.10+~cs22.25.14-8.

Fixed upstream in Debian (bug 1019291) by 1.22.19+~cs24.27.18-2, which has already been imported to Kinetic and Lunar, but not yet available for Jammy.

Original bug report from Debian issue tracker follows:

---

The current version of node-commander in Debian testing an unstable in 9.4.0.
However, this version is not fully compatible
with the current version of yarn.

For some packages, you will get something like this:

yarn run v1.22.19
TypeError: _commander(...).default.optionFor is not a function
    at /usr/share/nodejs/yarn/lib/cli/index.js:511:88
    at Array.findIndex (<anonymous>)
    at _callee$ (/usr/share/nodejs/yarn/lib/cli/index.js:507:38)
    at tryCatch
(/usr/share/nodejs/@babel/runtime/helpers/regeneratorRuntime.js:86:17)
    at Generator._invoke
(/usr/share/nodejs/@babel/runtime/helpers/regeneratorRuntime.js:66:24)
    at Generator.next
(/usr/share/nodejs/@babel/runtime/helpers/regeneratorRuntime.js:117:21)
    at asyncGeneratorStep
(/usr/share/nodejs/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next
(/usr/share/nodejs/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at /usr/share/nodejs/@babel/runtime/helpers/asyncToGenerator.js:32:7
    at new Promise (<anonymous>)

The short summary is that yarn tries to use the "optionFor" feature of
commnder,
but as far as I can tell, the last version of commander that still had
optionFor was version 4.1.1;
it has been removed by the time 5.0.0 has been released.

The upstream yarn package depends on "^2.9.0", so the currently packaged 9.4.0
definitely doesn't satisfy it.

Changed in node-yarnpkg (Ubuntu):
status: New → Incomplete
status: Incomplete → New
Revision history for this message
Mohammad Razavi (mrazavi) wrote (last edit ):

I have come up with a fix on yarnpkg that apparently will make it compatible with the newer version of commander. That could be used until someone ports the new version of yranpkg/berry to debian repositories:

```diff
--- node-yarnpkg_1.22.19.orig/src/cli/index.js
+++ node-yarnpkg_1.22.19/src/cli/index.js
@@ -147,7 +147,7 @@ export async function main({
   const firstNonFlagIndex = args.findIndex((arg, idx, arr) => {
     const isOption = arg.startsWith('-');
     const prev = idx > 0 && arr[idx - 1];
- const prevOption = prev && prev.startsWith('-') && commander.optionFor(prev);
+ const prevOption = prev && prev.startsWith('-') && commander.options.find(option => option.is(prev));
     const boundToPrevOption = prevOption && (prevOption.optional || prevOption.required);

     return !isOption && !boundToPrevOption;
```

I did not send this patch to the upstream as they do not accept non-security fixes for their older yarnpkg/yarn module, but I have used it on my PPA for Ubuntu 22.04 jammy series: https://launchpad.net/%7Emrazavi/+archive/ubuntu/gvm?field.series_filter=jammy

I propose to use this patch on the Ubuntu universe repositories until yarnpkg/berry is available. The latest version of yarnpkg even in lunar series will throw errors when you provide multiple arguments, for example:

yarnpkg -s -h

After installing the version from my PPA which includes this patch, the problem disappears.

Changed in node-yarnpkg (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.