element-hq / element-web

A glossy Matrix collaboration client for the web.
https://element.io
GNU Affero General Public License v3.0
11.21k stars 2k forks source link

Unable to start desktop app inside electron: app.makeSingleInstance is not a function #7945

Closed ploth closed 5 years ago

ploth commented 5 years ago

Description

npm run electron throws error

> riot-web@0.17.8 electron /home/ploth/projects/riot-web
> npm run install:electron && electron .

> riot-web@0.17.8 install:electron /home/ploth/projects/riot-web
> install-app-deps

  • please use as subcommand: electron-builder install-app-deps
  • electron-builder version=20.29.0
  • loaded configuration file=package.json ("build" field)
  • installing production dependencies platform=linux arch=x64 appDir=/home/ploth/projects/riot-web/electron_app
App threw an error during load
TypeError: app.makeSingleInstance is not a function
    at Object.<anonymous> (/home/ploth/projects/riot-web/electron_app/src/electron-main.js:103:24)
    at Object.<anonymous> (/home/ploth/projects/riot-web/electron_app/src/electron-main.js:277:3)
    at Module._compile (internal/modules/cjs/loader.js:693:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at loadApplicationPackage (/home/ploth/projects/riot-web/node_modules/electron/dist/resources/default_app.asar/main.js:119:12)
    at Object.<anonymous> (/home/ploth/projects/riot-web/node_modules/electron/dist/resources/default_app.asar/main.js:164:5)
    at Object.<anonymous> (/home/ploth/projects/riot-web/node_modules/electron/dist/resources/default_app.asar/main.js:204:3)
Unhandled exception TypeError: app.makeSingleInstance is not a function
    at Object.<anonymous> (/home/ploth/projects/riot-web/electron_app/src/electron-main.js:103:24)
    at Object.<anonymous> (/home/ploth/projects/riot-web/electron_app/src/electron-main.js:277:3)
    at Module._compile (internal/modules/cjs/loader.js:693:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at loadApplicationPackage (/home/ploth/projects/riot-web/node_modules/electron/dist/resources/default_app.asar/main.js:119:12)
    at Object.<anonymous> (/home/ploth/projects/riot-web/node_modules/electron/dist/resources/default_app.asar/main.js:164:5)
    at Object.<anonymous> (/home/ploth/projects/riot-web/node_modules/electron/dist/resources/default_app.asar/main.js:204:3)

Steps to reproduce

Expectation: Normal startup of the riot desktop client

Version information

$ npm --version
6.4.1
$ node --version
v8.12.0
t3chguy commented 5 years ago

Version of electron would be handy here.

ploth commented 5 years ago
$ npm install electron

> electron@4.0.0 postinstall /home/ploth/projects/riot-web/node_modules/electron
> node install.js

npm WARN slate@0.41.3 requires a peer of immutable@>=3.8.1 but none is installed. You must install peer dependencies yourself.
npm WARN slate-html-serializer@0.6.32 requires a peer of immutable@>=3.8.1 but none is installed. You must install peer dependencies yourself.
npm WARN slate-plain-serializer@0.6.33 requires a peer of immutable@>=3.8.1 but none is installed. You must install peer dependencies yourself.
npm WARN slate-prop-types@0.4.67 requires a peer of immutable@>=3.8.1 but none is installed. You must install peer dependencies yourself.
npm WARN slate-react@0.18.11 requires a peer of immutable@>=3.8.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-win@2.1.1 (node_modules/7zip-bin-win):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 7zip-bin-win@2.1.1: wanted {"os":"win32","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-mac@1.0.1 (node_modules/7zip-bin-mac):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 7zip-bin-mac@1.0.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ electron@4.0.0
updated 1 package and audited 21124 packages in 10.952s
found 5 vulnerabilities (4 low, 1 moderate)
  run `npm audit fix` to fix them, or `npm audit` for details
t3chguy commented 5 years ago

Try with electron 3, 4 is brand new and has removed that API. The change has already been merged to develop to stop using that removed API so you could equally switch branch. Though seeing some talk this morning I'm not sure if riot supports the brand new electron 4 in other ways yet, pending on a PR being released on their end

ploth commented 5 years ago

Works with electron 3.0.13. Thank you!

How to install electron 3?

npm install electron@3

lapineige commented 5 years ago

Hello,

It doesn't work for me with electron 3.1.1. What should I do ?

ploth commented 5 years ago

You can try to install the 3.0.13 version which is working for me.

npm install electron@3.0.13
lapineige commented 5 years ago

Where should I run this command ?

lapineige commented 5 years ago

In fact it seems to be already 3.0.13…

ploth commented 5 years ago

Do you have the same error once I had?

lapineige commented 5 years ago

I have this:

Unhandled exception TypeError: app.makeSingleInstance is not a function at Object. (/opt/Riot/resources/app/src/electron-main.js:103:24) at Object. (/opt/Riot/resources/app/src/electron-main.js:277:3) at Module._compile (internal/modules/cjs/loader.js:693:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10) at Module.load (internal/modules/cjs/loader.js:602:32) at tryModuleLoad (internal/modules/cjs/loader.js:541:12) at Function.Module._load (internal/modules/cjs/loader.js:533:3) at Object. (/opt/Riot/resources/electron.asar/browser/init.js:188:8) at Object. (/opt/Riot/resources/electron.asar/browser/init.js:190:3) at Module._compile (internal/modules/cjs/loader.js:693:30)

lapineige commented 5 years ago

Up. Does someone know how to fix this ? Even after some updates it doesn't work :(

lapineige commented 5 years ago

I found a solution.

For some reason, removing the package via apt didn't work. A part of the directory wasn't removed, even with purge command. So I uninstalled the package, then removed /opt/Riot/, and installed it again.

It works :)

gavv commented 5 years ago

Still reproducing for me.

I have run these commands:

git clone https://github.com/vector-im/riot-web.git
cd riot-web
yarn install
yarn build
yarn electron

And the output of the last one was:

yarn run v1.17.3
$ yarn install:electron && electron .
$ electron-builder install-app-deps
  • electron-builder version=20.44.4
  • loaded configuration file=package.json ("build" field)
  • installing production dependencies platform=linux arch=x64 appDir=/home/victor/dist/riot-web/electron_app

App threw an error during load
TypeError: protocol.registerSchemesAsPrivileged is not a function
    at Object.<anonymous> (/home/victor/dist/riot-web/electron_app/src/electron-main.js:238:10)
    at Object.<anonymous> (/home/victor/dist/riot-web/electron_app/src/electron-main.js:451:3)
    at Module._compile (internal/modules/cjs/loader.js:711:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:722:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
    at Function.Module._load (internal/modules/cjs/loader.js:551:3)
    at loadApplicationPackage (/usr/lib64/electron-3.1/resources/default_app.asar/main.js:286:12)
    at Object.<anonymous> (/usr/lib64/electron-3.1/resources/default_app.asar/main.js:327:5)
    at Object.<anonymous> (/usr/lib64/electron-3.1/resources/default_app.asar/main.js:364:3)
Unhandled exception TypeError: protocol.registerSchemesAsPrivileged is not a function
    at Object.<anonymous> (/home/victor/dist/riot-web/electron_app/src/electron-main.js:238:10)
    at Object.<anonymous> (/home/victor/dist/riot-web/electron_app/src/electron-main.js:451:3)
    at Module._compile (internal/modules/cjs/loader.js:711:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:722:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
    at Function.Module._load (internal/modules/cjs/loader.js:551:3)
    at loadApplicationPackage (/usr/lib64/electron-3.1/resources/default_app.asar/main.js:286:12)
    at Object.<anonymous> (/usr/lib64/electron-3.1/resources/default_app.asar/main.js:327:5)
    at Object.<anonymous> (/usr/lib64/electron-3.1/resources/default_app.asar/main.js:364:3)
^C
electron --version
v3.1.8

Also tried electron 2.0.17 and got the same results.

t3chguy commented 5 years ago

Use electron 5 as documented in package.json

gavv commented 5 years ago

@t3chguy thanks

I was (finally!) able to start riot by removing the system version of electron and installing the proper version via npm.

git clone https://github.com/vector-im/riot-web.git
cd riot-web
git checkout v1.3.2
cp config.sample.json config.json
yarn install
yarn build
npm install electron@5.0.7
yarn electron