Comment 1 for bug 2003697

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.