Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore with array of regexes causes ENOENT #557

Closed
3 tasks done
mako-taco opened this issue Aug 29, 2018 · 9 comments
Closed
3 tasks done

ignore with array of regexes causes ENOENT #557

mako-taco opened this issue Aug 29, 2018 · 9 comments

Comments

@mako-taco
Copy link

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Please describe your issue:
electron-forge package fails with the following message:

An unhandled error has occurred inside Forge:
ENOENT: no such file or directory, open '/var/folders/rr/8bhg8lwn65qbqjqbg6cgqt1n311f1x/T/electron-packager/darwin-x64/xxxx-darwin-x64/Electron.app/Contents/Resources/app/package.json'
Error: ENOENT: no such file or directory, open '/var/folders/rr/8bhg8lwn65qbqjqbg6cgqt1n311f1x/T/electron-packager/darwin-x64/xxxx-darwin-x64/Electron.app/Contents/Resources/app/package.json'

Console output when you run electron-forge with the environment variable DEBUG=electron-forge:*. (Instructions on how to do so here). Please include the stack trace if one exists.

WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:async-ora Process Started: Checking your system +0ms
  electron-forge:check-system checking system, create ~/.skip-forge-system-check to stop doing this +0ms
  electron-forge:async-ora Process Succeeded: Checking your system -- after 624ms +625ms
WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:async-ora Process Started: Preparing to Package Application for arch: x64 +0ms
  electron-forge:project-resolver searching for project in: /Users/xxxx/src/server/paper/etherpad/src/desktop +0ms
  electron-forge:project-resolver electron-forge compatible package.json found in /Users/xxxx/src/server/paper/etherpad/src/desktop/package.json +2ms
  electron-forge:hook hook triggered: resolveForgeConfig +0ms
  electron-forge:hook hook triggered: readPackageJson +1ms
  electron-forge:hook calling mutating hook: readPackageJson with item: { name: 'paper-desktop',
  productName: 'yyyy',
  version: '0.0.4',
  main: 'dist/build/main.js',
  scripts:
   { build: './bin/build.sh --mode development',
     watch: 'tsc -w',
     typecheck: 'tsc --noEmit',
     '//':
      '--enable-sandbox cannot be set due to a bug with IPC (https://github.com/electron/electron/issues/11922). See web_preference_verifier comment for more detail.',
     start:
      './node_modules/.bin/electron-forge start ./dist/build/main.js',
     debug:
      './node_modules/.bin/electron-forge start ./dist/build/main.js -- --inspect=12345',
     'debug-brk':
      './node_modules/.bin/electron-forge start ./dist/build/main.js -- --inspect-brk=12345',
     clean: './bin/clean.sh',
     make:
      './bin/clean.sh && ./bin/build.sh --mode production && ./node_modules/.bin/electron-forge make',
     package:
      './bin/clean.sh && ./bin/build.sh --mode production && ./node_modules/.bin/electron-forge package' },
  author: 'yyyy',
  license: 'Proprietary',
  config: { forge: './forge.config.js' },
  dependencies:
   { classnames: '^2.2.6',
     'yyyy-auth': '/Users/vagrant/src/client/app/lib/core/auth/node',
     'electron-log': '^2.1.0',
     'electron-store': '^2.0.0',
     react: '^16.2.0',
     'react-dom': '^16.2.0',
     rxjs: '5.4.3',
     'source-map-support': '^0.5.9' },
  devDependencies:
   { '@electron-forge/cli': '^6.0.0-beta.27',
     '@electron-forge/maker-squirrel': '^6.0.0-beta.27',
     '@types/classnames': '^2.2.6',
     '@types/electron-store': '^1.3.0',
     '@types/jest': '^22.2.3',
     browserify: '^16.2.2',
     'browserify-require-not-found-parent': '^0.1.0',
     cpx: '^1.5.0',
     'css-loader': '^1.0.0',
     electron: '2.0.2',
     'electron-forge':
      'https://github.com/electron-userland/electron-forge/#6.0.0-beta.27',
     'electron-squirrel-startup': '^1.0.0',
     'extract-loader': '^2.0.1',
     'file-loader': '^2.0.0',
     'html-loader': '^0.5.5',
     less: '^3.0.4',
     'less-loader': '^4.1.0',
     ncp: '^2.0.0',
     'node-loader': '^0.6.0',
     'style-loader': '^0.23.0',
     'ts-loader': '^4.5.0',
     tsify: '^4.0.0',
     tslib: '^1.9.3',
     typescript: '^2.6.2',
     webpack: '^4.17.1',
     'webpack-cli': '^3.1.0' } } +0ms
  electron-forge:hook hook triggered: generateAssets +2ms
  electron-forge:hook hook triggered: prePackage +0ms
  electron-forge:packager packaging with options { asar: false,
  overwrite: true,
  protocols:
   [ { protocol: 'yyyy-paper',
       name: 'yyyy Paper',
       schemes: 'yyyy-paper' } ],
  afterCopy: [ [Function] ],
  packageManager: 'yarn',
  icon:
   '/Users/xxxx/src/server/paper/etherpad/src/desktop/static/icon.icns',
  ignore: [ {}, {}, {}, {} ],
  dir: '/Users/xxxx/src/server/paper/etherpad/src/desktop',
  arch: 'x64',
  platform: 'darwin',
  afterExtract: [ [Function] ],
  afterPrune: [ [Function] ],
  out: '/Users/xxxx/src/server/paper/etherpad/src/desktop/out',
  electronVersion: '2.0.2',
  quiet: true } +0ms
  electron-forge:hook hook triggered: packageAfterExtract +2s
  electron-forge:async-ora Process Succeeded: Preparing to Package Application for arch: x64 -- after 1.7s +2s
  electron-forge:hook hook triggered: packageAfterCopy +57ms
  electron-forge:async-ora Process Started: Preparing native dependencies +1ms
  electron-forge:async-ora Process Failed: Preparing native dependencies () => {
    if (!startTime) return;
    return `-- after ${`${(0, _prettyMs.default)(Date.now() - startTime)}`.cyan}`;
  } +3ms

An unhandled error has occurred inside Forge:
ENOENT: no such file or directory, open '/var/folders/rr/8bhg8lwn65qbqjqbg6cgqt1n311f1x/T/electron-packager/darwin-x64/yyyy-darwin-x64/Electron.app/Contents/Resources/app/package.json'
Error: ENOENT: no such file or directory, open '/var/folders/rr/8bhg8lwn65qbqjqbg6cgqt1n311f1x/T/electron-packager/darwin-x64/yyyy-darwin-x64/Electron.app/Contents/Resources/app/package.json'

What command line arguments are you passing?

package

What does your config.forge data in package.json look like?

const rebuild = require('electron-rebuild').rebuid;
const path = require('path');
const packageJson = require('./package.json');

module.exports = {
  electronRebuildConfig: {},
  packagerConfig: {
    protocols: [
      {
        protocol: 'xxxx',
        name: 'xxxx',
        schemes: 'xxxx',
      },
    ],
    afterCopy: [
      (buildPath, electronVersion, platform, arch, callback) => {
        rebuild({buildPath, electronVersion, arch})
          .then(() => callback())
          .catch(error => callback(error));
      },
    ],
    packageManager: 'yarn',
    icon: path.resolve(__dirname, 'static/icon.icns'),
    ignore: [/\.tsx?$/, /^\/bin\//, /\/__mocks__\//, /^\/definitions\//],
  },
  makers: [
    {
      name: '@electron-forge/maker-squirrel',
    },
    {
      name: '@electron-forge/maker-zip',
    },
  ],
  hooks: {
    // Bug-- looks like electron-forge is reading THIS file instead of package.json
    readPackageJson(obj) {
      return packageJson;
    },
  },
};

Please provide either a failing minimal testcase (with a link to the code) or detailed steps to
reproduce your problem. Using electron-forge init is a good starting point, if that is not the
source of your problem.

I will supply this if the above logs are not enough, please let me know (it's crunch time at work)

Upon inspection, the temp folder contains only:
BUILD README.md

@malept
Copy link
Member

malept commented Aug 29, 2018

What version of Electron Forge is this?

Why do you have the afterCopy hook? You're basically running rebuild twice.

Why do you have the readPackageJson hook?

@mako-taco
Copy link
Author

  1. 6.0.0-beta27 (surprised that's not included in the DEBUG log)
  2. I had a package which was not being rebuilt -- this snippet is copy/pasted from one of these doc sites. Not sure if the hook is working either; I manually rebuilt and things worked after that.
  3. I was trying to debug error, thinking the ENOENT was coming during that step (it's not). Although I found it strange that the hook was passed the forge config (as opposed to package.json contents, like the docs suggest)

@mako-taco
Copy link
Author

mako-taco commented Aug 29, 2018

electron-rebuild is being called in the temp folder, where it expects to be able to read package.json, but it is not there.

⠋ Preparing native dependencies  electron-rebuild rebuilding with args: [Arguments] {
  '0':
   { buildPath:
      '/var/folders/rr/8bhg8lwn65qbqjqbg6cgqt1n311f1x/T/electron-packager/darwin-x64/xxxx-darwin-x64/Electron.app/Contents/Resources/app',
     electronVersion: '2.0.2',
     arch: 'x64' } } +63ms
  electron-rebuild rebuilding with args: /var/folders/rr/8bhg8lwn65qbqjqbg6cgqt1n311f1x/T/electron-packager/darwin-x64/xxxx-darwin-x64/Electron.app/Contents/Resources/app 2.0.2 x64 [] false https://atom.io/download/electron [ 'prod', 'optional' ] false +1ms
✖ Preparing native dependencies

Interestingly, commenting out my ignore lets the build progress further...

// ignore: [/\.tsx?$/, /^\/bin\//, /\/__mocks__\//, /^\/definitions\//],

This value for ignore produces the error:
ignore: [/WWWWWWW/]
while this runs fine:
ignore: ['WWWWWWW']
I'm guessing there's a boolean flip somewhere?

@mako-taco mako-taco changed the title package.json missing from temp folder ignore with array of regexes causes ENOENT Aug 29, 2018
@malept
Copy link
Member

malept commented Aug 29, 2018

I will supply this if the above logs are not enough, please let me know

Unfortunately, I need a minimal testcase.

@mako-taco
Copy link
Author

The broken behavior is from electron-packager's ignore function. Closing this issue.

@malept malept added the blocked/upstream Issues blocked by upstream bugs label Aug 29, 2018
@malept
Copy link
Member

malept commented Aug 29, 2018

I'm not convinced it's Electron Packager's fault. Try running with DEBUG="electron-forge:*,electron-packager". I mostly want to see what Packager thinks Forge is sending.

@mako-taco
Copy link
Author

Maybe a problem w/ passing literal regexp vs. strings-that-compile-to-regexp?

xxx-mbp:desktop xxx$ DEBUG="electron-forge:*,electron-packager" yarn package
yarn run v1.7.0
warning package.json: License should be a valid SPDX license expression
$ ./node_modules/.bin/electron-forge package
WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:async-ora Process Started: Checking your system +0ms
  electron-forge:check-system checking system, create ~/.skip-forge-system-check to stop doing this +0ms
  electron-forge:async-ora Process Succeeded: Checking your system -- after 724ms +724ms
WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:async-ora Process Started: Preparing to Package Application for arch: x64 +0ms
  electron-forge:project-resolver searching for project in: /Users/xxx/src/server/xxx/xxx/src/desktop +0ms
  electron-forge:project-resolver electron-forge compatible package.json found in /Users/xxx/src/server/xxx/xxx/src/desktop/package.json +3ms
  electron-forge:packager packaging with options { asar: true,
  overwrite: true,
  protocols:
   [ { protocol: 'xxx-xxx',
       name: 'xxx xxx',
       schemes: 'xxx-xxx' } ],
  packageManager: 'yarn',
  icon:
   '/Users/xxx/src/server/xxx/xxx/src/desktop/static/icon.icns',
  ignore: [ {}, {}, {}, {}, {}, {} ],
  dir: '/Users/xxx/src/server/xxx/xxx/src/desktop',
  arch: 'x64',
  platform: 'darwin',
  afterCopy: [ [Function] ],
  afterExtract: [ [Function] ],
  afterPrune: [ [Function] ],
  out: '/Users/xxx/src/server/xxx/xxx/src/desktop/out',
  electronVersion: '2.0.2',
  quiet: true } +0ms
  electron-packager Electron Packager 12.1.1
  electron-packager Node v10.8.0
  electron-packager Host Operating system: darwin (x64) +0ms
  electron-packager Packager Options: {"asar":true,"overwrite":true,"protocols":[{"protocol":"xxx-xxx","name":"xxx xxx","schemes":"xxx-xxx"}],"packageManager":"yarn","icon":"/Users/xxx/src/server/xxx/xxx/src/desktop/static/icon.icns","ignore":[{},{},{},{},{},{}],"dir":"/Users/xxx/src/server/xxx/xxx/src/desktop","arch":"x64","platform":"darwin","afterCopy":[null],"afterExtract":[null],"afterPrune":[null],"out":"/Users/xxx/src/server/xxx/xxx/src/desktop/out","electronVersion":"2.0.2","quiet":true} +0ms
  electron-packager Target Platforms: darwin +0ms
  electron-packager Target Architectures: x64 +0ms
  electron-packager Inferring application name from productName in /Users/xxx/src/server/xxx/xxx/src/desktop/package.json +0ms
  electron-packager Inferring appVersion from version in /Users/xxx/src/server/xxx/xxx/src/desktop/package.json +0ms
  electron-packager Application name: xxxxxx +6ms
  electron-packager Target Electron version: 2.0.2 +0ms
  electron-packager Ignored path regular expressions: [ {},
  {},
  {},
  {},
  {},
  {},
  '/\\.git($|/)',
  '/node_modules/\\.bin($|/)',
  '\\.o(bj)?$' ] +0ms
  electron-packager Downloading Electron with options {"platform":"darwin","arch":"x64","version":"2.0.2"} +0ms
  electron-packager Creating /var/folders/rr/8bhg8lwn65qbqjqbg6cgqt1n311f1x/T/electron-packager/darwin-x64-template +268ms
  electron-packager Extracting /Users/xxx/.electron/electron-v2.0.2-darwin-x64.zip to /var/folders/rr/8bhg8lwn65qbqjqbg6cgqt1n311f1x/T/electron-packager/darwin-x64-template +0ms
  electron-packager Initializing app in /var/folders/rr/8bhg8lwn65qbqjqbg6cgqt1n311f1x/T/electron-packager/darwin-x64/xxxxxx-darwin-x64 from /var/folders/rr/8bhg8lwn65qbqjqbg6cgqt1n311f1x/T/electron-packager/darwin-x64-template template +0ms
  electron-packager Ignored paths based on the out param: [ '/Users/xxx/src/server/xxx/xxx/src/desktop/out' ] +2s
  electron-forge:async-ora Process Succeeded: Preparing to Package Application for arch: x64 -- after 1.7s +2s
  electron-forge:async-ora Process Started: Preparing native dependencies +1ms
  electron-forge:async-ora Process Failed: Preparing native dependencies () => {
    if (!startTime) return;
    return `-- after ${`${(0, _prettyMs.default)(Date.now() - startTime)}`.cyan}`;
  } +2ms

An unhandled error has occurred inside Forge:
ENOENT: no such file or directory, open '/var/folders/rr/8bhg8lwn65qbqjqbg6cgqt1n311f1x/T/electron-packager/darwin-x64/xxxxxx-darwin-x64/Electron.app/Contents/Resources/app/package.json'
Error: ENOENT: no such file or directory, open '/var/folders/rr/8bhg8lwn65qbqjqbg6cgqt1n311f1x/T/electron-packager/darwin-x64/xxxxxx-darwin-x64/Electron.app/Contents/Resources/app/package.json'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
xxx-mbp:desktop xxx$

@malept
Copy link
Member

malept commented Sep 7, 2018

@MarshallOfSound I did some debugging and I found out that the proxify code in forge-config.ts is converting RegExp objects to empty Objects:

https://github.com/electron-userland/electron-forge/blob/6caa32a3cf69794218c84c0d87774f5560f62c70/packages/api/core/src/util/forge-config.ts#L12-L52

You can probably identify how to fix this faster than I can, but if you're too busy, I'll try to find some time to figure out how the function works.

@malept malept reopened this Sep 7, 2018
@malept malept added bug packager and removed blocked/upstream Issues blocked by upstream bugs labels Sep 7, 2018
@MarshallOfSound
Copy link
Member

@malept PR incoming 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants