holochain / holoscape

A complete end-user deployment of a Holochain conductor with UI for administration and a run-time for hApp UIs
63 stars 8 forks source link

Unable to run the Holoscape Electron package #34

Closed dhtnetwork closed 4 years ago

dhtnetwork commented 4 years ago

Notes from a user trying to run Holoscape.

=== My feedback on installing Holoscape and attempting to use it to bundle an app:

I used the same Vagrant VM (based on NixOS) in which I completed the "Install Holochain" tasks to attempt my installation of Holoscape. I ran into some problems, detailed in this journal, that prevented me from ultimately running the Holoscape Electron package.

Attempts to start Holoscape using the npm start invocation documented on the Holoscape README file returns an error:

[nix-shell:~/src/holoscape]$ npm start

> holoscape@0.0.1 start /home/vagrant/src/holoscape
> electron .

events.js:187
      throw er; // Unhandled 'error' event
      ^

Error: spawn /home/vagrant/src/holoscape/node_modules/electron/dist/electron ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn /home/vagrant/src/holoscape/node_modules/electron/dist/electron',
  path: '/home/vagrant/src/holoscape/node_modules/electron/dist/electron',
  spawnargs: [ '.' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! holoscape@0.0.1 start: `electron .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the holoscape@0.0.1 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!     /home/vagrant/.npm/_logs/2019-11-21T19_08_07_001Z-debug.log

I encountered a similar error when attempting to build the Linux variant of the stand-alone Holoscape package:

$ npm run build-linux

> holoscape@0.0.1 build-linux /home/vagrant/src/holoscape
> electron-packager . Holoscape --platform=linux --overwrite --icon=./images/HoloScape-hdpi.png

Packaging app for platform linux x64 using electron v6.1.5
Command failed: unzip -o "/home/vagrant/.cache/electron/httpsgithub.comelectronelectronreleasesdownloadv6.1.5electron-v6.1.5-linux-x64.zip/electron-v6.1.5-linux-x64.zip" -d "/tmp/tmp.MPA1PjDUTV/electron-packager/linux-x64-template"
/bin/sh: unzip: command not found

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! holoscape@0.0.1 build-linux: `electron-packager . Holoscape --platform=linux --overwrite --icon=./images/HoloScape-hdpi.png`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the holoscape@0.0.1 build-linux 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!     /home/vagrant/.npm/_logs/2019-11-21T19_19_07_587Z-debug.log

In this case, it was because the unzip command was not found. Installing this command on NixOS requires the addition of the nixos.unzip attribute to the running environment:

nix-env -iA nixos.unzip

With unzip installed, Holoscape can be built:

$ npm run build-linux

> holoscape@0.0.1 build-linux /home/vagrant/src/holoscape
> electron-packager . Holoscape --platform=linux --overwrite --icon=./images/HoloScape-hdpi.png

Packaging app for platform linux x64 using electron v6.1.5
Wrote new app to /home/vagrant/src/holoscape/Holoscape-linux-x64

Unfortunately, when attempting to run Holoscape, two additional problems present themselves:

  1. The electron binary is not yet in the path (because it has not been documented to be required). The fix, of course, is to add it to the shell's search path by ensuring that `./node_modules/.bin" is present.
    export PATH="$(pwd)/node_modules/.bin:$PATH" # Invoked from the same directory as `npm install` was run.

    Note that it is not feasible to easily install NPM packages globally in this NixOS environment because the NixOS package store is read-only. Thus, commands to workaround the Electron error such as npm install -g --unsafe-perm=true --allow-root fail with a filesystem-level "permission denied" error.

  2. Once the electron binary is available in the shell search path, the same error as when attempting to run Holoscape in its development mode presents itself:

    $ cd Holoscape-linux-x64/ && electron .
    events.js:187
        throw er; // Unhandled 'error' event
        ^
    
    Error: spawn /home/vagrant/src/holoscape/node_modules/electron/dist/electron ENOENT
      at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
      at onErrorNT (internal/child_process.js:456:16)
      at processTicksAndRejections (internal/process/task_queues.js:80:21)
    Emitted 'error' event on ChildProcess instance at:
      at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
      at onErrorNT (internal/child_process.js:456:16)
      at processTicksAndRejections (internal/process/task_queues.js:80:21) {
    errno: 'ENOENT',
    code: 'ENOENT',
    syscall: 'spawn /home/vagrant/src/holoscape/node_modules/electron/dist/electron',
    path: '/home/vagrant/src/holoscape/node_modules/electron/dist/electron',
    spawnargs: [ '.' ]
    }
    

While this may have been easier in an environment that is not based on NixOS, the path of least resistance for developers, which is to go from the NixOS-based Vagrant installation recommended on the Install documentation directly to the Holoscape application is clearly a rough experience and needs a lot of improvement to reduce these developer pain points.

@lucksus

thedavidmeister commented 4 years ago

@dhtnetwork there are nix commands documented in the readme nix-shell --run holoscape and nix-shell --run holoscape-flush that wrap electron correctly

lucksus commented 4 years ago

So these rather cryptic errors all boil down to a simple cause: the Holochain binaries are missing.

Last week we added a dialog to make this situation more clear if somebody runs into it: https://github.com/holochain/holoscape/pull/39

But above listings show a usage that is not documented anyway (i.e. just running npm start).

@thedavidmeister added a nix command holoscape that automatically pulls binaries from Holonix. This is also documented in the readme as the way to go. In the listings above, the user ran npm start directly without copying binaries manually and without running the documented nix command. Either should fix it.

thedavidmeister commented 4 years ago

note, the nix command copies the binaries into place and wraps the version of electron that is nix friendly (the one that npm drops into place will probably die if you try to use it directly)