Repository: electron
Issue: [Bug]: Cannot run electron-quick-start with sudo (tried with --no-sandbox)
Labels: bug :beetle:,15-x-y

### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a feature request that matches the one I want to file, without success.

### Electron Version

15.0.0

### What operating system are you using?

Ubuntu

### Operating System Version

20.04

### What arch are you using?

x64

### Last Known Working Electron version

_No response_

### Expected Behavior

Running `sudo npm start -- --no-sandbox` in a freshly cloned copy of the electron-quick-start repo will launch electron (after running `npm i`). Or alternatively modifying package.json to include the `--no-sandbox` option (`"start": "electron --no-sandbox ."`) and running `sudo npm start`.

### Actual Behavior

Get an error:
```
> electron-quick-start@1.0.0 start /home/data/temp/electron-quick-start
> electron . "--no-sandbox"

[17683:0926/083112.637987:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[17683:0926/083112.638052:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
No protocol specified
[17683:0926/083112.674009:ERROR:gpu_process_host.cc(957)] GPU process exited unexpectedly: exit_code=1024
No protocol specified
[17683:0926/083112.675415:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[17683:0926/083112.676871:ERROR:gpu_process_host.cc(957)] GPU process exited unexpectedly: exit_code=1024
No protocol specified
[17683:0926/083112.679479:ERROR:gpu_process_host.cc(957)] GPU process exited unexpectedly: exit_code=1024
No protocol specified
[17683:0926/083112.681905:ERROR:gpu_process_host.cc(957)] GPU process exited unexpectedly: exit_code=1024
No protocol specified
[17683:0926/083112.684603:ERROR:gpu_process_host.cc(957)] GPU process exited unexpectedly: exit_code=1024
No protocol specified
[17683:0926/083112.687832:ERROR:gpu_process_host.cc(957)] GPU process exited unexpectedly: exit_code=1024
No protocol specified
[17683:0926/083112.691204:ERROR:gpu_process_host.cc(957)] GPU process exited unexpectedly: exit_code=1024
No protocol specified
[17683:0926/083112.700030:ERROR:gpu_process_host.cc(957)] GPU process exited unexpectedly: exit_code=1024
No protocol specified
[17683:0926/083112.713117:ERROR:gpu_process_host.cc(957)] GPU process exited unexpectedly: exit_code=1024
[17683:0926/083112.713133:FATAL:gpu_data_manager_impl_private.cc(417)] GPU process isn't usable. Goodbye.
/home/data/temp/electron-quick-start/node_modules/electron/dist/electron exited with signal SIGTRAP
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron-quick-start@1.0.0 start: `electron . "--no-sandbox"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron-quick-start@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-09-25T22_31_12_848Z-debug.log
```

The log contains:
```
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start', '--', '--no-sandbox' ]
2 info using npm@6.14.15
3 info using node@v14.17.6
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle electron-quick-start@1.0.0~prestart: electron-quick-start@1.0.0
6 info lifecycle electron-quick-start@1.0.0~start: electron-quick-start@1.0.0
7 verbose lifecycle electron-quick-start@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle electron-quick-start@1.0.0~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/data/temp/electron-quick-start/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
9 verbose lifecycle electron-quick-start@1.0.0~start: CWD: /home/data/temp/electron-quick-start
10 silly lifecycle electron-quick-start@1.0.0~start: Args: [ '-c', 'electron . "--no-sandbox"' ]
11 silly lifecycle electron-quick-start@1.0.0~start: Returned: code: 1  signal: null
12 info lifecycle electron-quick-start@1.0.0~start: Failed to exec start script
13 verbose stack Error: electron-quick-start@1.0.0 start: `electron . "--no-sandbox"`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:400:28)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:400:28)
13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid electron-quick-start@1.0.0
15 verbose cwd /home/data/temp/electron-quick-start
16 verbose Linux 5.4.0-86-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start" "--" "--no-sandbox"
18 verbose node v14.17.6
19 verbose npm  v6.14.15
20 error code ELIFECYCLE
21 error errno 1
22 error electron-quick-start@1.0.0 start: `electron . "--no-sandbox"`
22 error Exit status 1
23 error Failed at the electron-quick-start@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
```

### Testcase Gist URL

_No response_

### Additional Information

I've spent hours looking around for answers, and have tried many of the things mentioned in other issues...

I'm actually wanting to use electron on a raspberry pi 4 (running as root to access GPIO, which requires root access to a particular device), and came across the same issue on there (running Ubuntu 21.04). I see exactly the same kind of error on that platform, but without the `ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")` errors, just:
```
> electron-quick-start@1.0.0 start
> electron . "--no-sandbox"

/home/oliver/electron-quick-start/node_modules/electron/dist/electron exited with signal SIGTRAP
npm ERR! code 1
npm ERR! path /home/oliver/electron-quick-start
npm ERR! command failed
npm ERR! command sh -c electron . "--no-sandbox"

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-09-25T22_07_14_997Z-debug.log
```

And the log appears the same too:
```
0 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start', '--', '--no-sandbox' ]
1 info using npm@7.5.2
2 info using node@v12.21.0
3 timing config:load:defaults Completed in 6ms
4 timing config:load:file:/usr/share/nodejs/npm/npmrc Completed in 7ms
5 timing config:load:builtin Completed in 7ms
6 timing config:load:cli Completed in 7ms
7 timing config:load:env Completed in 1ms
8 timing config:load:file:/home/oliver/electron-quick-start/.npmrc Completed in 1ms
9 timing config:load:project Completed in 3ms
10 timing config:load:file:/root/.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:/etc/npmrc Completed in 1ms
13 timing config:load:global Completed in 1ms
14 timing config:load:cafile Completed in 1ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 2ms
17 timing config:load:setEnvs Completed in 3ms
18 timing config:load Completed in 35ms
19 verbose npm-session 4c57081c36180441
20 timing npm:load Completed in 71ms
21 timing command:run-script Completed in 2122ms
22 timing command:start Completed in 2133ms
23 verbose stack Error: command failed
23 verbose stack     at ChildProcess.<anonymous> (/usr/share/nodejs/@npmcli/promise-spawn/index.js:64:27)
23 verbose stack     at ChildProcess.emit (events.js:314:20)
23 verbose stack     at maybeClose (internal/child_process.js:1022:16)
23 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
24 verbose pkgid electron-quick-start@1.0.0
25 verbose cwd /home/oliver/electron-quick-start
26 verbose Linux 5.11.0-1017-raspi
27 verbose argv "/usr/bin/node" "/usr/bin/npm" "start" "--" "--no-sandbox"
28 verbose node v12.21.0
29 verbose npm  v7.5.2
30 error code 1
31 error path /home/oliver/electron-quick-start
32 error command failed
33 error command sh -c electron . "--no-sandbox"
34 verbose exit 1
```