Bug 245425

Summary: www/yarn: throws error when global packages are installed, 1.22.4 regression
Product: Ports & Packages Reporter: Guido Falsi <madpilot>
Component: Individual Port(s)Assignee: Luca Pizzamiglio <pizzamig>
Status: Closed FIXED    
Severity: Affects Only Me Keywords: patch
Priority: --- Flags: pizzamig: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
See Also: https://github.com/yarnpkg/yarn/issues/4884
Attachments:
Description Flags
Patch none

Description Guido Falsi freebsd_committer freebsd_triage 2020-04-07 15:30:17 UTC
Created attachment 213157 [details]
Patch

Hi,

I noticed a regression with yarn 1.22.4. I have some local global packages installed with `yarn global add`.

The error is:

> yarn global upgrade
SyntaxError: Unknown token: { line: 1, col: 0, type: 'INVALID', value: undefined } 1:0 in yarnrc
    at Parser.unexpected (/usr/local/lib/node_modules/yarn/lib/cli.js:64332:11)
    at Parser.parse (/usr/local/lib/node_modules/yarn/lib/cli.js:64463:14)
    at parse (/usr/local/lib/node_modules/yarn/lib/cli.js:64537:21)
    at module.exports.exports.default (/usr/local/lib/node_modules/yarn/lib/cli.js:64099:96)
    at loadRcFile (/usr/local/lib/node_modules/yarn/lib/cli.js:56942:58)
    at /usr/local/lib/node_modules/yarn/lib/cli.js:56916:14
    at /usr/local/lib/node_modules/yarn/lib/cli.js:101331:14
    at Array.map (<anonymous>)
    at parseRcPaths (/usr/local/lib/node_modules/yarn/lib/cli.js:101329:78)
    at Object.findRc (/usr/local/lib/node_modules/yarn/lib/cli.js:101343:10)


and happens with any subcommand.

I studied the thing a little and found an upstream commit which is to blame. I reverted it locally with a patch to the port (attached), and the problem goes away.

I also followed up in an upstream issue report where someone else pointed out the same error on NetBSD:

https://github.com/yarnpkg/yarn/issues/4884

For reference the problematic upstream commit can be reached here:

https://github.com/yarnpkg/yarn/commit/2cb2fc4805060986c6d5cdf6b7636d91b441c38f
Comment 1 commit-hook freebsd_committer freebsd_triage 2020-04-14 15:34:58 UTC
A commit references this bug:

Author: pizzamig
Date: Tue Apr 14 15:34:40 UTC 2020
New revision: 531699
URL: https://svnweb.freebsd.org/changeset/ports/531699

Log:
  www/yarn: fix regression with global packages

  Add a patch to fix global packages upgrade

  PR:		245425
  Submitted by:	madpilot@
  Obtained from:	https://github.com/yarnpkg/yarn/issues/4884

Changes:
  head/www/yarn/Makefile
  head/www/yarn/files/
  head/www/yarn/files/patch-lib_cli.js
Comment 2 Luca Pizzamiglio freebsd_committer freebsd_triage 2020-04-14 15:38:23 UTC
Committed! Thanks!