octalmage / robotjs

Node.js Desktop Automation.
http://robotjs.io
MIT License
12.37k stars 961 forks source link

Build error when deploying to Heroku #579

Closed PhilipLemaster closed 4 years ago

PhilipLemaster commented 4 years ago

Expected Behavior

Having difficulty deploying my app to a Heroku server. The package runs beautifully when running the server on localhost and am trying to deploy the webapp that features this package to a server.

Current Behavior

My git push heroku master will not complete a build in order for my webapp to be deployed. Even after successfully completing the prebuild steps, the deployment halts when trying to build this package. Below is the error log that I see when attempting to push:

-----> Node.js app detected

-----> Creating runtime environment

   NPM_CONFIG_LOGLEVEL=error
   NODE_ENV=production
   NODE_MODULES_CACHE=true
   NODE_VERBOSE=false

-----> Installing binaries engines.node (package.json): 12.16.3 engines.npm (package.json): unspecified (use default)

   Resolving node version 12.16.3...
   Downloading and installing node 12.16.3...
   Using default npm version: 6.14.4

-----> Installing dependencies Installing node modules (package.json)

   > robotjs@0.6.0 install /tmp/build_282ad2c2c5d3423dd109ed9515ef6acb/node_modules/robotjs
   > prebuild-install || node-gyp rebuild

   make: Entering directory '/tmp/build_282ad2c2c5d3423dd109ed9515ef6acb/node_modules/robotjs/build'
     CXX(target) Release/obj.target/robotjs/src/robotjs.o
   cc1plus: warning: command line option ‘-Wbad-function-cast’ is valid for C/ObjC but not for C++
   ../src/robotjs.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE keyToggle(Nan::NAN_METHOD_ARGS_TYPE)’:
   ../src/robotjs.cc:595:17: warning: ‘down’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       toggleKeyCode(key, down, flags);
       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
   In file included from ../../nan/nan_new.h:189:0,
                    from ../../nan/nan.h:290,
                    from ../src/robotjs.cc:2:
   ../../nan/nan_implementation_12_inl.h: In function ‘void InitAll(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’:
   ../../nan/nan_implementation_12_inl.h:119:1: warning: inlining failed in call to ‘static Nan::imp::FactoryBase<v8::FunctionTemplate>::return_t Nan::imp::Factory<v8::FunctionTemplate>::New(Nan::FunctionCallback, v8::Local<v8::Value>, v8::Local<v8::Signature>)’: --param large-function-growth limit reached [-Winline]
    Factory<v8::FunctionTemplate>::New( FunctionCallback callback
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from ../../nan/nan.h:290:0,
                    from ../src/robotjs.cc:2:
   ../../nan/nan_new.h:239:47: note: called from here
        return imp::Factory<T>::New(callback, data);
                                                  ^
   In file included from ../../nan/nan_new.h:189:0,
                    from ../../nan/nan.h:290,
                    from ../src/robotjs.cc:2:
   ../../nan/nan_implementation_12_inl.h:119:1: warning: inlining failed in call to ‘static Nan::imp::FactoryBase<v8::FunctionTemplate>::return_t Nan::imp::Factory<v8::FunctionTemplate>::New(Nan::FunctionCallback, v8::Local<v8::Value>, v8::Local<v8::Signature>)’: --param large-function-growth limit reached [-Winline]
    Factory<v8::FunctionTemplate>::New( FunctionCallback callback
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from ../../nan/nan.h:290:0,
                    from ../src/robotjs.cc:2:
   ../../nan/nan_new.h:239:47: note: called from here
        return imp::Factory<T>::New(callback, data);
                                                  ^
   In file included from ../../nan/nan_new.h:189:0,
                    from ../../nan/nan.h:290,
                    from ../src/robotjs.cc:2:
   ../../nan/nan_implementation_12_inl.h:119:1: warning: inlining failed in call to ‘static Nan::imp::FactoryBase<v8::FunctionTemplate>::return_t Nan::imp::Factory<v8::FunctionTemplate>::New(Nan::FunctionCallback, v8::Local<v8::Value>, v8::Local<v8::Signature>)’: --param large-function-growth limit reached [-Winline]
    Factory<v8::FunctionTemplate>::New( FunctionCallback callback
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from ../../nan/nan.h:290:0,
                    from ../src/robotjs.cc:2:
   ../../nan/nan_new.h:239:47: note: called from here
        return imp::Factory<T>::New(callback, data);
                                                  ^
   In file included from ../../nan/nan_new.h:189:0,
                    from ../../nan/nan.h:290,
                    from ../src/robotjs.cc:2:
   ../../nan/nan_implementation_12_inl.h:119:1: warning: inlining failed in call to ‘static Nan::imp::FactoryBase<v8::FunctionTemplate>::return_t Nan::imp::Factory<v8::FunctionTemplate>::New(Nan::FunctionCallback, v8::Local<v8::Value>, v8::Local<v8::Signature>)’: --param large-function-growth limit reached [-Winline]
    Factory<v8::FunctionTemplate>::New( FunctionCallback callback
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from ../../nan/nan.h:290:0,
                    from ../src/robotjs.cc:2:
   ../../nan/nan_new.h:239:47: note: called from here
        return imp::Factory<T>::New(callback, data);
                                                  ^
   In file included from ../../nan/nan_new.h:189:0,
                    from ../../nan/nan.h:290,
                    from ../src/robotjs.cc:2:
   ../../nan/nan_implementation_12_inl.h:119:1: warning: inlining failed in call to ‘static Nan::imp::FactoryBase<v8::FunctionTemplate>::return_t Nan::imp::Factory<v8::FunctionTemplate>::New(Nan::FunctionCallback, v8::Local<v8::Value>, v8::Local<v8::Signature>)’: --param large-function-growth limit reached [-Winline]
    Factory<v8::FunctionTemplate>::New( FunctionCallback callback
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from ../../nan/nan.h:290:0,
                    from ../src/robotjs.cc:2:
   ../../nan/nan_new.h:239:47: note: called from here
        return imp::Factory<T>::New(callback, data);
                                                  ^
   In file included from ../../nan/nan_new.h:189:0,
                    from ../../nan/nan.h:290,
                    from ../src/robotjs.cc:2:
   ../../nan/nan_implementation_12_inl.h:119:1: warning: inlining failed in call to ‘static Nan::imp::FactoryBase<v8::FunctionTemplate>::return_t Nan::imp::Factory<v8::FunctionTemplate>::New(Nan::FunctionCallback, v8::Local<v8::Value>, v8::Local<v8::Signature>)’: --param large-function-growth limit reached [-Winline]
    Factory<v8::FunctionTemplate>::New( FunctionCallback callback
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from ../../nan/nan.h:290:0,
                    from ../src/robotjs.cc:2:
   ../../nan/nan_new.h:239:47: note: called from here
        return imp::Factory<T>::New(callback, data);
                                                  ^
     CC(target) Release/obj.target/robotjs/src/deadbeef_rand.o
     CC(target) Release/obj.target/robotjs/src/mouse.o
   ../src/mouse.c:12:11: fatal error: X11/extensions/XTest.h: No such file or directory
     #include <X11/extensions/XTest.h>
              ^~~~~~~~~~~~~~~~~~~~~~~~
   compilation terminated.
   robotjs.target.mk:133: recipe for target 'Release/obj.target/robotjs/src/mouse.o' failed
   make: *** [Release/obj.target/robotjs/src/mouse.o] Error 1
   make: Leaving directory '/tmp/build_282ad2c2c5d3423dd109ed9515ef6acb/node_modules/robotjs/build'
   gyp ERR! build error 
   gyp ERR! stack Error: `make` failed with exit code: 2
   gyp ERR! stack     at ChildProcess.onExit (/tmp/build_282ad2c2c5d3423dd109ed9515ef6acb/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
   gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
   gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
   gyp ERR! System Linux 4.4.0-1066-aws
   gyp ERR! command "/tmp/build_282ad2c2c5d3423dd109ed9515ef6acb/.heroku/node/bin/node" "/tmp/build_282ad2c2c5d3423dd109ed9515ef6acb/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
   gyp ERR! cwd /tmp/build_282ad2c2c5d3423dd109ed9515ef6acb/node_modules/robotjs
   gyp ERR! node -v v12.16.3
   gyp ERR! node-gyp -v v5.1.0
   gyp ERR! not ok 
   npm ERR! code ELIFECYCLE
   npm ERR! errno 1
   npm ERR! robotjs@0.6.0 install: `prebuild-install || node-gyp rebuild`
   npm ERR! Exit status 1
   npm ERR! 
   npm ERR! Failed at the robotjs@0.6.0 install 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!     /tmp/npmcache.n1EfN/_logs/2020-05-13T22_46_43_365Z-debug.log

-----> Build failed

   We're sorry this build is failing! You can troubleshoot common issues here:
   https://devcenter.heroku.com/articles/troubleshooting-node-deploys

   If you're stuck, please submit a ticket so we can help:
   https://help.heroku.com/

   Love,
   Heroku

! Push rejected, failed to compile Node.js app. ! Push failed

Possible Solution

I am unsure if this is a problem with how I prepared node-gyp or another prerequisite requirement for the package to build properly, as I am somewhat new to working in node, however I have tried troubleshooting for dozens of solutions and have yet to find a way to fix this.

Context

Like referenced above, the package runs locally exactly as expected. Encountered this issue when attempting to deploy to both Heroku and also DigitalOcean servers.

Your Environment

zenflow commented 4 years ago

But @PhilipLemaster my dude... This library is for desktop automation, and on Heroku cloud hosting environment there is no desktop. Even if you could get your app to build, how would you expect this library to behave in an environment where there is no desktop?

PhilipLemaster commented 4 years ago

I'm pretty new to hosting on Heroku and maybe I'm pushing for this package to be used beyond it's scope. I currently have an app set up with automation functions bound to buttons that the user can click on a server. Given that the app works as expected on localhost, I guess I made the assumption that the same could be said when hosting the app to a nonlocal server. If this is not the case, I apologize.

zenflow commented 4 years ago

If this is not the case, I apologize.

There's nobody to apologize to :)

Given that the app works as expected on localhost, I guess I made the assumption that the same could be said when hosting the app to a nonlocal server

Oh I can definitely see how someone could make that assumption. But now you understand why it won't work, right? This library is for interacting with a desktop GUI. Therefore it requires the machine to have a desktop GUI to drive. Non-local servers typically do not have a desktop GUI because it's not needed because we use other ways to control it.

I suggest that, if possible, whatever you were doing with this library and a GUI, you should figure out how to do it with execa and a CLI.

PhilipLemaster commented 4 years ago

Yeah, that makes perfect sense! Appreciate the clarification :)