Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Build Error on Ubuntu #297

Closed
naveen26246 opened this issue Jun 7, 2017 · 19 comments
Closed

Build Error on Ubuntu #297

naveen26246 opened this issue Jun 7, 2017 · 19 comments

Comments

@naveen26246
Copy link

I came across the following error while trying to run ./build.sh --enable-nodejs-binding:


/home/bhagawat/sdks/iot-edge/proxy/gateway/nodejs/lib/codec.js:61
function decodeMessageChannelUri(buf, offset = 0) {
^

SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/home/bhagawat/sdks/iot-edge/proxy/gateway/nodejs/test/codec_test.js:10:13)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at /home/bhagawat/sdks/iot-edge/proxy/gateway/nodejs/node_modules/mocha/lib/mocha.js:230:27
at Array.forEach (native)
at Mocha.loadFiles (/home/bhagawat/sdks/iot-edge/proxy/gateway/nodejs/node_modules/mocha/lib/mocha.js:227:14)
at Mocha.run (/home/bhagawat/sdks/iot-edge/proxy/gateway/nodejs/node_modules/mocha/lib/mocha.js:495:10)
at Object. (/home/bhagawat/sdks/iot-edge/proxy/gateway/nodejs/node_modules/mocha/bin/_mocha:469:18)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
npm ERR! Test failed. See above for more details.

Any leads to address the issue?

@abhatikar
Copy link

I too faced the same issue on Ubuntu 16.04

abhatikar@raspberry-pi:/Code/iot-edge$ export NODE_INCLUDE="/home/abhatikar/Code/iot-edge/build_nodejs/dist/inc"
abhatikar@raspberry-pi:
/Code/iot-edge$ export NODE_LIB="/home/abhatikar/Code/iot-edge/build_nodejs/dist/lib"
abhatikar@raspberry-pi:/Code/iot-edge$
abhatikar@raspberry-pi:
/Code/iot-edge$ cd tools/
abhatikar@raspberry-pi:~/Code/iot-edge/tools$ ./build.sh --enable-nodejs-binding
~/Code/iot-edge/samples/nodejs_remote_sample ~/Code/iot-edge/tools
npm WARN nodejs-remote-sample@0.0.1 No repository field.

nodejs-remote-sample@0.0.1 lint /home/abhatikar/Code/iot-edge/samples/nodejs_remote_sample
jshint --show-non-errors .

~/Code/iot-edge/tools
~/Code/iot-edge/proxy/gateway/nodejs ~/Code/iot-edge/tools
npm WARN azure-iot-proxy-gateway@0.0.1 No repository field.

azure-iot-proxy-gateway@0.0.1 lint /home/abhatikar/Code/iot-edge/proxy/gateway/nodejs
jshint --show-non-errors .

azure-iot-proxy-gateway@0.0.1 test /home/abhatikar/Code/iot-edge/proxy/gateway/nodejs
mocha

/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/lib/codec.js:61
function decodeMessageChannelUri(buf, offset = 0) {
^

SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/test/codec_test.js:10:13)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at /home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/node_modules/mocha/lib/mocha.js:230:27
at Array.forEach (native)
at Mocha.loadFiles (/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/node_modules/mocha/lib/mocha.js:227:14)
at Mocha.run (/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/node_modules/mocha/lib/mocha.js:495:10)
at Object. (/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/node_modules/mocha/bin/_mocha:469:18)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
npm ERR! Test failed. See above for more details.
abhatikar@raspberry-pi:~/Code/iot-edge/tools$

@camauser
Copy link

camauser commented Jun 7, 2017

I was tying to build on Ubuntu 16.04 yesterday and ran into a similar issue when following the hello-world sample. I eventually solved this particular issue by installing NodeJS according to this guide on TecAdmin.net.

Unfortunately that didn't completely solve the build problems I was having. Now when I attempt to build, this is the output. (Pastebin link because GitHub is assuming some characters are for formatting)

Now the output looks good - everything is passing, there are a few warnings, but no errors. However, when I navigate to my iot-edge directory, there is no build subdirectory present after running the build.sh script. build.sh also exits with an error code of 1, so it seems that the script knows that it's encountering an error, but it just isn't displaying any information about the error to the screen.

Has anybody run into this issue? If so, do you have a fix for it?

@damonbarry
Copy link
Member

@naveen26246 @abhatikar @camauser What version of Node.js do you have on your Ubuntu machine?

I suspect your version of Node.js doesn't support some of the ES6 features we're using in our new Node.js out-of-process modules feature, but I need to investigate.

In thinking about it, I'm also realizing that this new feature should probably be OFF by default, since there's no guarantee that users will have Node.js installed. I'll work on that now...

@damonbarry
Copy link
Member

damonbarry commented Jun 7, 2017

I reproduced this issue by installing the default Node.js and npm on Ubuntu 16.04:

sudo apt-get install nodejs npm nodejs-legacy

This brings down Node.js v4.2.6, which doesn't support some of the Node/JavaScript features we're using in Node.js out-of-process modules, like default parameter values, Buffer.from() static method, etc.

I'm going to do two things to fix this right now:

  1. Disable the Node.js out-of-process modules feature by default
  2. Document that Node.js v6.0 or greater is required to use this feature (6.11 is the current LTS).

Stay tuned...

@camauser
Copy link

camauser commented Jun 7, 2017

@damonbarry According to node -v, I'm using Node.js v8.0.0 - this would explain why I wasn't receiving the same error as @naveen26246 and @abhatikar , but I'm still running into issues with v8.0.0 (see my message above).

damonbarry added a commit to damonbarry/iot-edge-v1 that referenced this issue Jun 7, 2017
@damonbarry
Copy link
Member

damonbarry commented Jun 7, 2017

@camauser It looks like there's some sort of silent error in our build script, but I'm not sure what it is. To help narrow it down, can you give me the output of dpkg-query -l curl build-essential libcurl4-openssl-dev git cmake libssl-dev uuid-dev valgrind libglib2.0-dev libtool autoconf?

@damonbarry
Copy link
Member

Reopening while we investigate @camauser's issue.

@abhatikar
Copy link

abhatikar commented Jun 8, 2017

autoconf 2.69-9
build-essential 12.1ubuntu2
cmake 3.5.1-1ubuntu3
curl 7.47.0-1ubuntu2
git 1:2.7.4-0ubuntu
libcurl4-openssl-dev 7.47.0-1ubuntu2
libglib2.0-dev 2.48.2-0ubuntu1
libssl-dev:amd64 1.0.2g-1ubuntu4
libtool 2.4.6-0.1
uuid-dev:amd64 2.27.1-6ubuntu3
valgrind 1:3.11.0-1ubunt

Node version
node -v
v6.11.0

@abhatikar
Copy link

abhatikar@raspberry-pi:~/Code/iot-edge/tools$ ./build.sh --enable-nodejs-binding --enable-nodejs-remote-modules
~/Code/iot-edge/samples/nodejs_remote_sample ~/Code/iot-edge/tools
npm WARN nodejs-remote-sample@0.0.1 No repository field.

nodejs-remote-sample@0.0.1 lint /home/abhatikar/Code/iot-edge/samples/nodejs_remote_sample
jshint --show-non-errors .

~/Code/iot-edge/tools
~/Code/iot-edge/proxy/gateway/nodejs ~/Code/iot-edge/tools
npm WARN azure-iot-proxy-gateway@0.0.1 No repository field.

azure-iot-proxy-gateway@0.0.1 lint /home/abhatikar/Code/iot-edge/proxy/gateway/nodejs
jshint --show-non-errors .

azure-iot-proxy-gateway@0.0.1 test /home/abhatikar/Code/iot-edge/proxy/gateway/nodejs
mocha

/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/node_modules/bindings/bindings.js:83
throw e
^

Error: Module version mismatch. Expected 48, got 46.
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at bindings (/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/node_modules/bindings/bindings.js:76:44)
at Object. (/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/node_modules/nanomsg/lib/index.js:1:102)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/lib/channel.js:9:12)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/test/channel_test.js:7:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/node_modules/mocha/lib/mocha.js:230:27
at Array.forEach (native)
at Mocha.loadFiles (/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/node_modules/mocha/lib/mocha.js:227:14)
at Mocha.run (/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/node_modules/mocha/lib/mocha.js:495:10)
at Object. (/home/abhatikar/Code/iot-edge/proxy/gateway/nodejs/node_modules/mocha/bin/_mocha:469:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
npm ERR! Test failed. See above for more details.
abhatikar@raspberry-pi:~/Code/iot-edge/tools$

@naveen26246
Copy link
Author

The build worked with nodejs v6.11.0 . Thanks @damonbarry @camauser

@camauser
Copy link

camauser commented Jun 8, 2017

@damonbarry Here is the output of the command you requested I run: Pastebin link

@damonbarry
Copy link
Member

damonbarry commented Jun 8, 2017

@abhatikar I reproduced the issue you're seeing (you're on Pi, I'm on a Docker Ubuntu 16.04 container, but same error). Here's how I encountered it:

apt-get install -y nodejs npm nodejs-legacy # installs v4.2.6
git clone https://github.com/azure/iot-edge.git
cd iot-edge
tools/build.sh --enable-nodejs-remote-modules # produces the original error for this GitHub issue
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs # installs v8.0.0
tools/build.sh --enable-nodejs-remote-modules # produces your error, in the nanomsg binding

I fixed the problem by cleaning the repo before building again:

git clean -xdf .
tools/build.sh --enable-nodejs-remote-modules # build succeeds

I think your error was just some weird interaction between the old and new versions of Node.js. Specifically, the nanomsg module uses node-gyp to build its underlying C library, and I'm pretty sure C interop is not compatible between major versions of Node.js. So using nanomsg built from an older version of Node.js isn't guaranteed to work. Deleting the proxy/gateway/nodejs/node_modules/ folder forces everything to rebuild, and then it works.

Can you trying cleaning/rebuilding the iot-edge code, as I did above?

@damonbarry
Copy link
Member

@camauser I'm not able to reproduce what you're seeing. Can you try our build script again, but add a -x argument to the end (so that each line that executes is printed to the screen) and paste the output again?

@camauser
Copy link

camauser commented Jun 8, 2017

@damonbarry Sure, here's a link to the output of the command with the -x switch: Link

damonbarry added a commit to damonbarry/iot-edge-v1 that referenced this issue Jun 8, 2017
@damonbarry
Copy link
Member

@camauser The following command in the build script:

CORES2=$(expr ${MEMAR[0]} / 500000)

Evaluates to this in your environment:

expr 498380 / 500000

...which returns the value 0. That's all fine, except that the exit status of the expr command in this case is non-zero, so the set -e command at the top of the script causes the script to exit.

Since we care about the expression result and not the exit status of expr, I've made a pull request that causes the script to disregard the exit status of this particular command.

@camauser
Copy link

camauser commented Jun 9, 2017

@damonbarry Thanks for the information and the fix - I pulled the new version of master and I'm now able to build and run the hello_world sample! Feel free to mark this issue as solved, unless anybody else is still having similar issues.

@damonbarry
Copy link
Member

Awesome!

@abhatikar
Copy link

@damonbarry Thanks everything is working now on a fresh checkout and build.Please close the issue.

@damonbarry
Copy link
Member

Available in the 2017-08-21 release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants