question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Electron fails to start when running as root on Linux

See original GitHub issue
  • 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: I’m trying to get electron-forge 6 working in a Docker environment. When I attempt to run the following minimal example, it appears to build correctly but then immediately exits with no error code.

Dockerfile:

FROM node:8.16.0-stretch

RUN npm install -g npx

WORKDIR /usr/src
RUN npx create-electron-app webpack-demo --template=webpack
WORKDIR /usr/src/webpack-demo

RUN apt-get update
RUN apt-get install libnss3 libgtk-3-0 libxss1 libasound2 -y

ENV DEBUG electron-forge:*

CMD ["npm", "start"]

I see the same behavior if I run npm start manually within the container after getting into bash (docker run -it webpack-template bash), and echo $? returns 0.

Running ls .webpack in the container shows only the main directory, where I believe there should also be a renderer directory:

root@99e500936bf5:/usr/src/webpack-demo# ls .webpack
main

If I do npx create-electron-app webpack-demo --template=webpack on my Mac, I am able to npm start successfully and I see a .webpack/renderer dir. It seems like something is preventing the renderer build from succeeding in the Docker/Debian environment?

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.

Output from running docker build -t webpack-template . && docker run webpack-template with the above Dockerfile

> webpack-demo@1.0.0 start /usr/src/webpack-demo
> electron-forge start

WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
2019-07-12T07:16:33.111Z electron-forge:async-ora Process Started: Checking your system
2019-07-12T07:16:33.122Z electron-forge:check-system checking system, create ~/.skip-forge-system-check to stop doing this
2019-07-12T07:16:33.769Z electron-forge:async-ora Process Succeeded: Checking your system -- after 657ms
WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
2019-07-12T07:16:34.805Z electron-forge:async-ora Process Started: Locating Application
2019-07-12T07:16:34.808Z electron-forge:project-resolver searching for project in: /usr/src/webpack-demo
2019-07-12T07:16:34.813Z electron-forge:project-resolver electron-forge compatible package.json found in /usr/src/webpack-demo/package.json
2019-07-12T07:16:34.815Z electron-forge:async-ora Process Succeeded: Locating Application -- after 9ms
2019-07-12T07:16:34.827Z electron-forge:require-search searching [ '@electron-forge/plugin-webpack',
  '/usr/src/webpack-demo/@electron-forge/plugin-webpack',
  '/usr/src/webpack-demo/node_modules/@electron-forge/plugin-webpack' ] relative to /usr/src/webpack-demo
2019-07-12T07:16:34.831Z electron-forge:require-search testing @electron-forge/plugin-webpack
2019-07-12T07:16:35.582Z electron-forge:plugin:webpack hooking process events
2019-07-12T07:16:35.629Z electron-forge:async-ora Process Started: Preparing native dependencies
2019-07-12T07:16:36.572Z electron-forge:async-ora Process Succeeded: Preparing native dependencies -- after 943ms
2019-07-12T07:16:36.575Z electron-forge:plugins plugin: "webpack" has taken control of the start command
2019-07-12T07:16:36.589Z electron-forge:async-ora Process Started: Compiling Main Process Code
2019-07-12T07:16:37.519Z electron-forge:async-ora Process Succeeded: Compiling Main Process Code -- after 930ms
2019-07-12T07:16:37.520Z electron-forge:async-ora Process Started: Launch Dev Servers
2019-07-12T07:16:37.574Z electron-forge:async-ora Process Succeeded: Launch Dev Servers -- after 54ms
2019-07-12T07:16:37.574Z electron-forge:async-ora Process Started: Compiling Preload Scripts
2019-07-12T07:16:37.576Z electron-forge:async-ora Process Succeeded: Compiling Preload Scripts -- after 2ms
2019-07-12T07:16:37.581Z electron-forge:async-ora Process Started: Launching Application
2019-07-12T07:16:37.591Z electron-forge:async-ora Process Succeeded: Launching Application -- after 10ms
2019-07-12T07:16:37.594Z electron-forge:plugin:webpack hooking electron process exit


Webpack Output Available: http://localhost:9000

2019-07-12T07:16:37.663Z electron-forge:plugin:webpack handling process exit with: { cleanup: true, exit: true }
2019-07-12T07:16:37.664Z electron-forge:plugin:webpack cleaning webpack watcher
2019-07-12T07:16:37.667Z electron-forge:plugin:webpack cleaning http server
2019-07-12T07:16:37.668Z electron-forge:plugin:webpack stopping logger
2019-07-12T07:16:37.669Z electron-forge:plugin:webpack handling process exit with: { cleanup: true }
Arics-MB-Pro:forge-webpack-bug aric$

What command line arguments are you passing? None

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

I’m using the webpack template from npx create-electron-app webpack-demo --template=webpack as is with no modifications.

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.

  1. Have Docker installed
  2. Copy minimal Dockerfile above to a new dir
  3. In the dir, run docker build -t webpack-template . && docker run webpack-template

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
maleptcommented, Jul 12, 2019

is it possible to pass the --no-sandbox flag to Electron when using forge?

See https://www.electronforge.io/cli#start

0reactions
concretedcommented, Jul 12, 2019

Alternatively, is it possible to pass the --no-sandbox flag to Electron when using forge?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron fails to start when running as root on Linux #1015
When I attempt to run the following minimal example, it appears to build correctly but then immediately exits with no error code. Dockerfile...
Read more >
Fixing a baffling issue when running Electron as root in GNU ...
After diving into the Electron codebase, the root of the error is file_. IsValid() , a utility function from Chromium, which returns -1...
Read more >
Running electron as root on Linux - node.js - Stack Overflow
it looks like a problem of environment variables. The environmnet variables are set for your user but not for root.
Read more >
Advanced Installation Instructions | Electron
To install prebuilt Electron binaries, use npm. The preferred method is to install Electron as a development dependency in your app:
Read more >
Bug #1944468 “Electron applications all crash upon launch”
When either application was provided "--no-sandbox" at the command line, they would run normally. However, Element does not pass that via ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found