tessel / t2-cli

Tessel 2 Command Line Interface
MIT License
114 stars 56 forks source link

unable to use Google Cloud gcloud library #645

Closed ptone closed 8 years ago

ptone commented 8 years ago

This is using https://github.com/GoogleCloudPlatform/gcloud-node

`googcloud$ t2 run index.js INFO Looking for your Tessel... INFO Connected to ptone-t. INFO Building project. WARN Pre-compiled module is missing: grpc. This might be caused by any of the following:

  1. The binary is platform specific and cannot be compiled for OpenWRT.
  2. A pre-compiled binary has not yet been generated for this module.
  3. The binary didn't compile correctly for the platform that you're developing on. It's possible that the binary is Linux-only or even OpenWRT specific, try npm installing with "--force" and rerun your deployment command.

Please file an issue at https://github.com/tessel/t2-cli/issues/new WARN Pre-compiled module is missing: sse4_crc32. This might be caused by any of the following:

  1. The binary is platform specific and cannot be compiled for OpenWRT.
  2. A pre-compiled binary has not yet been generated for this module.
  3. The binary didn't compile correctly for the platform that you're developing on. It's possible that the binary is Linux-only or even OpenWRT specific, try npm installing with "--force" and rerun your deployment command.

Please file an issue at https://github.com/tessel/t2-cli/issues/new INFO Writing project to RAM on ptone-t (2469.888 kB)... INFO Deployed. INFO Running index.js... module.js:339 throw err; ^

Error: Cannot find module './aes' at Function.Module._resolveFilename (module.js:337:15) at Function.Module._load (module.js:287:25) at Module.require (module.js:366:17) at require (module.js:385:17) at /tmp/remote-script/node_modules/node-forge/js/forge.js:1:358 at Array.map (native) at Module.e.exports (/tmp/remote-script/node_modules/node-forge/js/forge.js:1:335) at i (/tmp/remote-script/node_modules/node-forge/js/forge.js:1:515) at /tmp/remote-script/node_modules/node-forge/js/forge.js:1:1060 at define (/tmp/remote-script/node_modules/node-forge/js/forge.js:1:268)`

With a simple test app of:

` var gcloud = require('gcloud')({ projectId: 'neon-chimera-121918', keyFilename: 'cloud-key.json' });

var gcs = gcloud.storage();

gcs.getBuckets() .on('error', console.error) .on('data', function(bucket) { console.log(bucket); }) .on('end', function() { // All buckets retrieved. }); `

rwaldron commented 8 years ago

Thanks! We'll get a precompiled module onto the server as soon as possible (I'm mobile at the moment, otherwise I'd do it immediately).

Cc @reconbot

rwaldron commented 8 years ago

Ok, I came back to give this a try...

anandsuresh commented 8 years ago

@rwaldron Can you please post some logs for the sse4_crc32 compile failure?

rwaldron commented 8 years ago

@anandsuresh thanks for answering my call for help! Here's what I've got:

node-pre-gyp rebuild --target_platform=linux --target_arch=mipsel --target=4.2.1 --debug
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.6.26
node-pre-gyp info using node@4.2.1 | linux | x64
gyp info it worked if it ends with ok
gyp info using node-gyp@3.3.1
gyp info using node@4.2.1 | linux | x64
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@3.3.1
gyp info using node@4.2.1 | linux | x64
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/home/vagrant/.nvm/versions/node/v4.2.1/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/work/binary-module/package/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/work/binary-module/package/common.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/vagrant/.nvm/versions/node/v4.2.1/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/vagrant/.node-gyp/4.2.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/vagrant/.node-gyp/4.2.1',
gyp info spawn args   '-Dnode_gyp_dir=/home/vagrant/.nvm/versions/node/v4.2.1/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/work/binary-module/package',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@3.3.1
gyp info using node@4.2.1 | linux | x64
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Debug', '-C', 'build' ]
make: Entering directory `/work/binary-module/package/build'
  CXX(target) Debug/obj.target/crc32c_sse42/src/crc32c_sse42.o
mipsel-openwrt-linux-uclibc-g++: error: unrecognized command line option '-msse4.2'
make: *** [Debug/obj.target/crc32c_sse42/src/crc32c_sse42.o] Error 1
make: Leaving directory `/work/binary-module/package/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/vagrant/.nvm/versions/node/v4.2.1/lib/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 3.13.0-77-generic
gyp ERR! command "/home/vagrant/.nvm/versions/node/v4.2.1/bin/node" "/home/vagrant/.nvm/versions/node/v4.2.1/bin/node-gyp" "build" "--target_platform=linux" "--target_arch=mipsel" "--target=4.2.1" "--debug" "--module=/work/binary-module/package/out/Release/sse4_crc32.node" "--module_name=sse4_crc32" "--module_path=/work/binary-module/package/out/Release"
gyp ERR! cwd /work/binary-module/package
gyp ERR! node -v v4.2.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/home/vagrant/.nvm/versions/node/v4.2.1/bin/node /home/vagrant/.nvm/versions/node/v4.2.1/bin/node-gyp build --target_platform=linux --target_arch=mipsel --target=4.2.1 --debug --module=/work/binary-module/package/out/Release/sse4_crc32.node --module_name=sse4_crc32 --module_path=/work/binary-module/package/out/Release' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/vagrant/.nvm/versions/node/v4.2.1/lib/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:818:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Linux 3.13.0-77-generic
node-pre-gyp ERR! command "/home/vagrant/.nvm/versions/node/v4.2.1/bin/node" "/home/vagrant/.nvm/versions/node/v4.2.1/bin/node-pre-gyp" "rebuild" "--target_platform=linux" "--target_arch=mipsel" "--target=4.2.1" "--debug"
node-pre-gyp ERR! cwd /work/binary-module/package
node-pre-gyp ERR! node -v v4.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.26
node-pre-gyp ERR! not ok
Failed to execute '/home/vagrant/.nvm/versions/node/v4.2.1/bin/node /home/vagrant/.nvm/versions/node/v4.2.1/bin/node-gyp build --target_platform=linux --target_arch=mipsel --target=4.2.1 --debug --module=/work/binary-module/package/out/Release/sse4_crc32.node --module_name=sse4_crc32 --module_path=/work/binary-module/package/out/Release' (1)

The cross compilation tool is here: https://github.com/tessel/t2-compiler

rwaldron commented 8 years ago

Thanks to @anandsuresh for all his work getting sse4_crc32 updated! I've just compiled sse4_crc32@0.5.0 and pushed it to the precompiled binary server. @ptone can you give this a run through? Thank you!

ptone commented 8 years ago

is there some index on the precompiled binary server that isn't getting updated somewhere?

I deleted and reinstalled local node_modules with npm, but still get

ptone-macpro:googcloud$ t2 run index.js 
INFO Looking for your Tessel...
INFO Connected to ptone-t.
INFO Building project.
WARN Pre-compiled module is missing: sse4_crc32.
This might be caused by any of the following:

1. The binary is platform specific and cannot be compiled for OpenWRT.
2. A pre-compiled binary has not yet been generated for this module.
3. The binary didn't compile correctly for the platform that you're developing on.
    It's possible that the binary is Linux-only or even OpenWRT specific,
    try npm installing with "--force" and rerun your deployment command.

Please file an issue at https://github.com/tessel/t2-cli/issues/new
INFO Writing project to RAM on ptone-t (5111.808 kB)...
INFO Deployed.
INFO Running index.js...
module.js:339
    throw err;
    ^

Error: Cannot find module './aes'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at /tmp/remote-script/node_modules/node-forge/js/forge.js:1:358
    at Array.map (native)
    at Module.e.exports (/tmp/remote-script/node_modules/node-forge/js/forge.js:1:335)
    at i (/tmp/remote-script/node_modules/node-forge/js/forge.js:1:515)
    at /tmp/remote-script/node_modules/node-forge/js/forge.js:1:1060
    at define (/tmp/remote-script/node_modules/node-forge/js/forge.js:1:268)
rwaldron commented 8 years ago

is there some index on the precompiled binary server that isn't getting updated somewhere?

Nope, direct file requests.

I deleted and reinstalled local node_modules with npm, but still get

Well, I guess that's because the dependency is still ^4.1.0? https://github.com/ashi009/node-fast-crc32c/pull/7 While we await that update, I did this:

npm install sse4_crc32@5.0.0;
rm -r node_modules/fast-crc32c/node_modules/sse4_crc32/; # dispose of the out of date version

Then I deployed without seeing that message above. Then I hit the second problem shown in your output above: node-forge appears to dynamically require(...) much of its internals, which means t2 cli can't detect dependencies during the deployment operation (which uses the same static analysis as browserify to build dep graph). So I created a .tesselinclude in my root and added the following:

node_modules/node-forge/js/*.js

That fixes the Error: Cannot find module './aes' problem, but then fast-crc32c fails:

Error: Failed to find available CRC-32C implementation.

Because that project ALSO does dynamic require(...), so I add this to .tesselinclude as well...

node_modules/node-forge/js/*.js
node_modules/fast-crc32c/impls/*.js

And now it loads fully, but still has this message:

D0407 18:44:09.862040000    1509 env_linux.c:66]             Warning: insecure environment read function 'getenv' used

However, that's out of scope for this project to address

rwaldron commented 8 years ago

I will file PRs to those projects to add .tesselinclude files tomorrow.

ptone commented 8 years ago

Great - I had already done the explicit install of 5.0.0 (in the rare chance someone else hits this thread. the 0.5.0 in a comment above is a typo).

But I had not removed the other version.

I have it running now, tessel talking to GCP - woot.

rwaldron commented 8 years ago

That's great news!