google / closure-compiler-npm

Package for managing and documenting closure-compiler for use via npm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yarn's plug-n-play (pnp) breaks javaPath in `spawn` on osx

seamusleahy opened this issue · comments

I ran into an issue using Yarn's plug-n-play (PNP) where the precompiled osx closure compiler cannot be spawned. I assume it is because of PNP the path to the JAR is inside a zip file instead of to a direct file as with the non-PNP version.

I was able to get it to work by unplugging the google-closure-compiler-osx package which unzips the contents and the JAR is a file again.

A quick readthrough of Yarn's docs seems to offer two solutions:

  1. Set the preferUnplugged in package.json of the google-closure-compiler-osx package.
  2. Set the dependenciesMeta/unplugged in package.json of the google-closure-compiler package.

System: macOS 10.15.1
Node: v12.16.2
Yarn: 2.0.0-rc.32
google-closure-compiler: 20200406.0.0

Steps to reproduce

Setup:

mkdir gcc-pnp
cd gcc-pnp
yarn set version berry
yarn init
yarn add --dev google-closure-compiler

Run pnp version of package:

yarn google-closure-compiler

Output of error:

internal/child_process.js:407
    throw errnoException(err, 'spawn');
    ^

Error: spawn ENOTDIR
    at ChildProcess.spawn (internal/child_process.js:407:11)
    at spawn (child_process.js:548:9)
    at Compiler.run (/Users/seamusleahy/projects/gcc-pnp/.yarn/cache/google-closure-compiler-npm-20200406.0.0-d048db9c29-2.zip/node_modules/google-closure-compiler/lib/node/closure-compiler.js:76:26)
    at Object.<anonymous> (/Users/seamusleahy/projects/gcc-pnp/.yarn/cache/google-closure-compiler-npm-20200406.0.0-d048db9c29-2.zip/node_modules/google-closure-compiler/cli.js:106:12)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.module_1.Module._load (/Users/seamusleahy/projects/gcc-pnp/.pnp.js:9500:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  errno: 'ENOTDIR',
  code: 'ENOTDIR',
  syscall: 'spawn'
}

Fix it by unplugging compiled osx

yarn unplug google-closure-compiler-osx
yarn google-closure-compiler

Output:

The compiler is waiting for input via stdin.

Finally package.json

{
  "name": "gcc-pnp",
  "devDependencies": {
    "google-closure-compiler": "^20200406.0.0"
  },
  "dependenciesMeta": {
    "google-closure-compiler-osx": {
      "unplugged": true
    }
  }
}

Chad, would you be looking into this issue?

Would you be willing to put together @seamusleahy a PR?

I will put a PR together

Sorry - catching up now.

I think we'll need to do this for every binary version (basically everything except the JS version).