eouia / MMM-Assistant

(Deprecated) This project is not supported any more from original owner. Use alternative MMM-AssistantMk2(https://github.com/eouia/MMM-AssistantMk2)
https://github.com/eouia/MMM-AssistantMk2
MIT License
25 stars 8 forks source link

Not able to install #22

Open E3V3A opened 6 years ago

E3V3A commented 6 years ago

Hi @eouia

I'm following your wiki instructions, but the installation fails with:

$ npm install

> snowboy@1.2.0 preinstall /home/pi/MagicMirror/modules/MMM-Assistant/node_modules/snowboy
> npm install node-pre-gyp

npm notice created a lockfile as package-lock.json. You should commit this file.
+ node-pre-gyp@0.6.39
added 113 packages from 75 contributors in 34.586s

> grpc@1.3.2 install /home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp ERR! Tried to download(403): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.3.2/node-v59-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for grpc@1.3.2 and node@9.8.0 (node-v59 ABI) (falling back to source compile with node-gyp)
make: Entering directory '/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/grpc/build'
  CC(target) Release/obj.target/grpc/src/core/lib/surface/init.o
...

That file does not exist and seem outdated. But I found one here: https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.7.1/node-v59-linux-arm.tar.gz

However, I don't know where that file belong, do you? Either way, I did this:

cd ~/Downloads
wget https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.7.1/node-v59-linux-arm.tar.gz
tar -zxvf node-v59-linux-arm.tar.gz 
cd node-v59-linux-arm
mkdir -p /home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/grpc/src/node/extension_binary/node-v59-linux-arm/
cp grpc_node.node /home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/grpc/src/node/extension_binary/node-v59-linux-arm/.
cd /home/pi/MagicMirror/modules/MMM-Assistant/
npm install

That resulted in the following message:

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN MMM-Assistant@1.0.0 No repository field.
npm WARN MMM-Assistant@1.0.0 No license field.

removed 23 packages in 26.832s

Not sure if this went well, because I cut the install short the first time when it failed finding that file.

So I did this:

E3V3A commented 6 years ago

So tried to do the auth thing, that also failed:

$ node google-auth.js

module.js:545
    throw err;
    ^
Error: Cannot find module '/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/grpc/src/node/extension_binary/grpc_node.node'
    at Function.Module._resolveFilename (module.js:543:15)
    at Function.Module._load (module.js:470:25)
    at Module.require (module.js:593:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/grpc/src/node/src/grpc_extension.js:38:15)
    at Module._compile (module.js:649:30)
    at Object.Module._extensions..js (module.js:660:10)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:501:12)
    at Function.Module._load (module.js:493:3)

# Manually copied grpc to its place, then ran:
$ node google-auth.js

/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/grpc/src/node/src/server.js:702
  code: grpc.status.UNIMPLEMENTED,
                    ^

TypeError: Cannot read property 'UNIMPLEMENTED' of undefined
    at Object.<anonymous> (/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/grpc/src/node/src/server.js:702:21)
    at Module._compile (module.js:649:30)
    at Object.Module._extensions..js (module.js:660:10)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:501:12)
    at Function.Module._load (module.js:493:3)
    at Module.require (module.js:593:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/grpc/src/node/index.js:47:14)
    at Module._compile (module.js:649:30)

:broken_heart:

This is the same issue as in #11

E3V3A commented 6 years ago

@eouia Perhaps this could have something to do with this?

Google changed their Assistant API to include model-id: Assistant(credentials, device_model_id)...

eouia commented 6 years ago

Well, First, sorry for my late update. I should do my job so I couldn't make time to maintain this. I hope I could get the time in a month.

I hadn't tested but I suspect it was caused by the old version dependencies in package.json. I had to fix the version constantly for escaping some urgent bugs at that time a few months ago. After time, it makes my code to be unstable.

I have no time to research it currently, But if you have some luck, this could be a help. Reinstall it with this package.json

{
  "name": "MMM-Assistant",
  "version": "1.0.0",
  "dependencies": {
    "@google-cloud/speech": "^0.10.3",
    "google-assistant": "^0.1.12",
    "node-aplay": "^1.0.3",
    "node-record-lpcm16": "^0.3.0",
    "snowboy": "^1.2.0",
    "speaker": "^0.4.0"
  },
  "devDependencies": {
    "electron-rebuild": "^1.6.0",
    "yarg": "^1.0.8"
  }
}
E3V3A commented 6 years ago
  1. ok, it made two manual compiles with lots of deprecation warnings.
node-pre-gyp ERR! Tried to download(403): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.3.2/node-v59-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for grpc@1.3.2 and node@9.8.0 (node-v59 ABI) (falling back to source compile with node-gyp)
make: Entering directory '/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/grpc/build'
...
  SOLINK_MODULE(target) Release/obj.target/grpc_node.node
  COPY Release/grpc_node.node
  COPY /home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/grpc/src/node/extension_binary/grpc_node.node
  TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory '/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/grpc/build'

> grpc@1.10.0 install /home/pi/MagicMirror/modules/MMM-Assistant/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

[grpc] Success: "/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/grpc/src/node/extension_binary/node-v59-linux-arm-glibc/grpc_node.node" is installed via remote

> snowboy@1.2.0 install /home/pi/MagicMirror/modules/MMM-Assistant/node_modules/snowboy
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(403): https://snowboy-release-node.s3-us-west-2.amazonaws.com/snowboy/v1.2.0/Release/snowboy-v1.2.0-node-v59-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for snowboy@1.2.0 and node@9.8.0 (node-v59 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory '/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/snowboy/build'

added 541 packages from 212 contributors in 705.378s

real    11m48.474s
  1. Then the google_auth.js copy paste worked, even with this error:
    
    $ node google-auth.js

Attempted to automatically open the URL, but if it failed, copy/paste this in your browser: https://accounts.google.com/o/oauth2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fassistant-sdk-prototype&response_type=code&client_id=xxxxx-yyyyy.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob Paste your code: (node:3869) UnhandledPromiseRejectionWarning: Error: Exited with code 3 at ChildProcess.cp.once.code (/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/opn/index.js:84:13) at Object.onceWrapper (events.js:272:13) at ChildProcess.emit (events.js:180:13) at maybeClose (internal/child_process.js:936:16) at Socket.stream.socket.on (internal/child_process.js:353:11) at Socket.emit (events.js:180:13) at Pipe._handle.close [as _onclose] (net.js:538:12) (node:3869) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:3869) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Google Authentication is finished. Press Ctrl+C for quit. ^C ``` * How can we fix? 3. The post installation part take too long... * Why is the post installation part needed? What does it do exactly? ```bash npm install --save-dev electron-rebuild && ./node_modules/.bin/electron-rebuild --pre-gyp-fix ``` It took ~ 25 min (RPi3)
eouia commented 6 years ago
  1. Why is the gRPC so old? I haven't updated the package.json for newer dependencies. new gRPC is published a few months ago(one or two months). I had no time to update it. npm tried to install many dependencies with newer version, but I fixed it with some specific versions. That makes this kind of warnings and errors.

  2. How can we fix?(Google Auth.js) Regardless of errors, if you can get token.js in resources directory, you don't have to care this error anymore. Just forget it. Anyway, this error is caused by version of node of MagicMirror. As I know, MM use lower version node for stability. Google-Auth.js uses some functions in higher node version. I doubt this error is placed when you try this again after recompilation.

  3. That point is the core problem on the installment of this module. MagicMirror, Google Assistant, Google Cloud Speech and Snowboy are using DIFFERENT VERSION OF NODE AND DEPENDENCIES EACH OTHER. That commands makes some node dependencies executable by recompiling after installment. By example, google-auth.js will be failed after this recompile. So you should finish step 3-1 before 4. And current snowboy modules doesn't work with current MagicMirror Electron version. So in step 4, it is recompiled for compatibility.

E3V3A commented 6 years ago

Thanks for your effort in explaining! I'm very grateful. :1st_place_medal: