Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detected CLI crash [SyntaxError: Unexpected end of input] SyntaxError: Unexpected end of input #807

Closed
vzamfirescu opened this issue Jul 23, 2016 · 19 comments

Comments

@vzamfirescu
Copy link

Hello Everyone,

I finally got my Tessel 2 to work on Windows 10 x64, but when I try running the starting project, I get the following error:

ERR! Detected CLI crash [SyntaxError: Unexpected end of input] SyntaxError: Unexpected end of input
ERR!     at Object.parse (native)
ERR!     at C:\Users\<MY_USER>\AppData\Roaming\npm\node_modules\t2-cli\lib\preferences.js:57:26
ERR!     at C:\Users\<MY_USER>\AppData\Roaming\npm\node_modules\t2-cli\node_modules\fs-extra\node_modules\graceful-fs\graceful-fs.js:78:16
ERR!     at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

I have tried reinstalling t2-cli, but it didn't fix my issue.

Furthermore, as I saw that the default project's index.js requires the 'tessel' module, I went on and installed that one as well, even though it was not specified under dependencies in package.json

After installing the 'tessel' module, when I run t2 run index.js I get some additional lines of text before getting the exact same error stack trace as above:

t2 run index.js
INFO Looking for your Tessel...
INFO Connected to <MY_TESSEL_DEVICE_NAME>
INFO Building project.
ERR! Detected CLI crash [SyntaxError: Unexpected end of input] SyntaxError: Unexpected end of input
ERR!     at Object.parse (native)
ERR!     at C:\Users\<MY_USER>\AppData\Roaming\npm\node_modules\t2-cli\lib\preferences.js:57:26
ERR!     at C:\Users\<MY_USER>\AppData\Roaming\npm\node_modules\t2-cli\node_modules\fs-extra\node_modules\graceful-fs\graceful-fs.js:78:16
ERR!     at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

I have to mention that the above error stack trace continues to be log indefinitely, until I interrupt the process.

Before installing the 'tessel' module locally in the project folder, I wouldn't even get the text lines from above - the one with Connected... and the one with Building project...

@HipsterBrown
Copy link
Contributor

@vzamfirescu Sorry you're running into this issue.

Furthermore, as I saw that the default project's index.js requires the 'tessel' module, I went on and installed that one as well, even though it was not specified under dependencies in package.json

The tessel module doesn't need to be installed locally because it lives on the device, in the firmware.

Also, what version of Node and npm are you using? You can find that out by running node -v and npm -v. Tessel currently supports Node version 4.2.0 to 5.0.

If you haven't done this yet, can you turn on the Crash Reporter in the cli? This is done by running t2 crash-reporter --on, and it will help us debug the problem further. That will send a report to this app, http://crash-reporter.tessel.io, where we can view a full debug log.

@vzamfirescu
Copy link
Author

vzamfirescu commented Jul 24, 2016

Sorry for not specifying the Node and npm version in my initial post:

node -v
v4.4.7

npm -v
2.15.8

I tried enabling the crash-reporter before posting an issue on GitHub, but I get the exact same error when running t2 crash-reporter --on:

ERR! Detected CLI crash [SyntaxError: Unexpected end of input] SyntaxError: Unexpected end of input
ERR!     at Object.parse (native)
ERR!     at C:\Users\<MY_USER>\AppData\Roaming\npm\node_modules\t2-cli\lib\preferences.js:57:26
ERR!     at C:\Users\<MY_USER>\AppData\Roaming\npm\node_modules\t2-cli\node_modules\fs-extra\node_modules\graceful-fs\graceful-fs.js:78:16
ERR!

@johnnyman727
Copy link
Contributor

@vzamfirescu we put out a new release (0.0.24) that may fix this issue. Could you update your CLI (npm i t2-cli -g) and give this a try again?

@vzamfirescu
Copy link
Author

vzamfirescu commented Jul 27, 2016

@johnnyman727 Thank you for your update!

I updated t2-cli and tried running t2 run index.js again, but I get the same error:

$ t2 version
INFO Looking for your Tessel...
INFO Connected to beast.
INFO Tessel [beast] CLI version: 0.0.24
INFO Tessel [beast] Firmware version: 0.0.13
INFO Tessel [beast] Node version: 4.4.3
ERR! Detected CLI crash [SyntaxError: Unexpected end of input] SyntaxError: Unexpected end of input
ERR!     at Object.parse (native)
ERR!     at C:\Users\<MY_USER>\AppData\Roaming\npm\node_modules\t2-cli\lib\preferences.js:57:26
ERR!     at C:\Users\<MY_USER>\AppData\Roaming\npm\node_modules\t2-cli\node_modules\fs-extra\node_modules\graceful-fs\graceful-fs.js:78:16
ERR!     at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

@rwaldron
Copy link
Contributor

This happens when you have a syntax error. Can you post the code you're trying deploy?

@vzamfirescu
Copy link
Author

I simply copied the example code from here - http://tessel.github.io/t2-start/blinky.html

// Import the interface to Tessel hardware
var tessel = require('tessel');

// Turn one of the LEDs on to start.
tessel.led[2].on();

// Blink!
setInterval(function () {
  tessel.led[2].toggle();
  tessel.led[3].toggle();
}, 100);

console.log("I'm blinking! (Press CTRL + C to stop)");

@rwaldron
Copy link
Contributor

Do have Screenhero (or some similar desktop remoting software)? Would you be willing to do remote desktop sharing session with me?

@vzamfirescu
Copy link
Author

Sure - is TeamViewer ok? (the free version, for non-commercial purposes)

@rwaldron
Copy link
Contributor

Got it! I'm not going to be available until sometime tomorrow, can you email at [email protected] and we can figure out a good time to do this?

@vzamfirescu
Copy link
Author

@rwaldron
Hey, Rick!
I've sent you an e-mail 2 days ago to schedule the screen sharing session. Did you receive it?

Moreover, I've tried uninstalling the t2-cli package and reinstall it afterwards, but the same error keeps persisting.

I've also tried running a different bit of code - a simple console.log('Some random text'), but no luck whatsoever - the same error keeps popping up, preventing me from running any piece of code on the Tessel 2.

@vzamfirescu
Copy link
Author

vzamfirescu commented Aug 1, 2016

I managed to finally get it to work by following the stack trace in each of the indicated lines in my initial error.

Thus, I ended up opening the preferences.json in my home folder on Win, under /.tessel/, which was completely empty, as I had to create it right after installing t2-cli.

Below is the content that I had to add to preferences.json because it appears that it needs to actually recognize it as JSON compliant:

{}

After adding the pair of brackets to the preferences.json file, the code ran, but I received a new error this time:

ERR! Detected CLI crash [TypeError: process.stdin.setRawMode is not a function] TypeError: process.stdin.setRawMode is not a function
ERR!     at Object.exportables.postRun (C:\Users\vladz\AppData\Roaming\npm\node_modules\t2-cli\lib\tessel\deployment\javascript.js:76:19)
ERR!     at C:\Users\vladz\AppData\Roaming\npm\node_modules\t2-cli\lib\tessel\deploy.js:388:18
ERR!     at C:\Users\vladz\AppData\Roaming\npm\node_modules\t2-cli\lib\lan-connection.js:94:12
ERR!     at C:\Users\vladz\AppData\Roaming\npm\node_modules\t2-cli\node_modules\ssh2\lib\client.js:1251:5
ERR!     at SSH2Stream.<anonymous> (C:\Users\vladz\AppData\Roaming\npm\node_modules\t2-cli\node_modules\ssh2\lib\Channel.js:177:24)
ERR!     at emitNone (events.js:67:13)
ERR!     at SSH2Stream.emit (events.js:166:7)
ERR!     at parsePacket (C:\Users\vladz\AppData\Roaming\npm\node_modules\t2-cli\node_modules\ssh2\node_modules\ssh2-streams\lib\ssh.js:3213:10)
ERR!     at SSH2Stream._transform (C:\Users\vladz\AppData\Roaming\npm\node_modules\t2-cli\node_modules\ssh2\node_modules\ssh2-streams\lib\ssh.js:551:13)
ERR!     at SSH2Stream.Transform._read (_stream_transform.js:167:10)
undefinedSubmit Crash Report to help Tessel Developers improve the CLI ?
    If yes(y), subsequent crashes will be submitted automatically. (Y/n)

@HipsterBrown
Copy link
Contributor

@vzamfirescu Are you using the latest version of t2-cli? There was a fix for that issue in a recent release -> #800. It may have been released after this issue was opened. Thank you for your patience and helping us debug the problem.

@rwaldron
Copy link
Contributor

rwaldron commented Aug 1, 2016

@vzamfirescu sorry, I was travelling and had a unexpected delay from Seattle to Boston that messed my whole day up on Friday, then we had Nodebots Day on Saturday. The issue you discovered is what I expected we'd find. Here was my plan:

  1. Have you reproduce the error for me
  2. Have you find and view the contents of the preferences.json file

I'm sorry this has been so problematic for you. I'm not sure why installing the latest version didn't resolve the issue, as @HipsterBrown indicated that it should have.

As far as this:

ERR! Detected CLI crash [TypeError: process.stdin.setRawMode is not a function] TypeError: process.stdin.setRawMode is not a function

I'm not sure what this could be. I'd like to ask that you npm uninstall -g t2-cli, then check your home dir and delete any .tessel directory if it exists. Then do a fresh install of the latest t2-cli

@vzamfirescu
Copy link
Author

vzamfirescu commented Aug 1, 2016

@HipsterBrown I double-checked the timestamp on my initial t2-cli installation and it is after the implementation of the fix that you mentioned

@rwaldron no problem! I know that schedules can get a bit too crowded from time to time :)

I somehow managed to fix this CLI crash as well - it appears it had something to do with me running the code from GitBash on Windows. As soon as I switched over to CMD, the code runs perfectly.

I will also reinstall t2-cli and try setting up the ambient module afterwards because even if standard JavaScript code runs ok, when I try running the example code for the ambient module, I get the following error:

we had a socket err { [Error: connect EAGAIN /var/run/tessel/port_a]
  code: 'EAGAIN',
  errno: 'EAGAIN',
  syscall: 'connect',
  address: '/var/run/tessel/port_a' }
/usr/lib/node/tessel-export.js:196
    throw new Error('Port socket closed');
    ^

Error: Port socket closed
    at Socket.<anonymous> (/usr/lib/node/tessel-export.js:196:11)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at Pipe._onclose (net.js:477:12)

UPDATE: Reinstalled t2-cli, it correctly initialized the .tessel folder, but I still get the above error when trying to use the ambient module

@rwaldron
Copy link
Contributor

rwaldron commented Aug 1, 2016

I somehow managed to fix this CLI crash as well - it appears it had something to do with me running the code from GitBash on Windows. As soon as I switched over to CMD, the code runs perfectly.

Ah, yeah... that makes sense. The windows support is for use with the built-in cmd.exe (see: http://tessel.github.io/t2-start/, under the Windows tab)

I will also reinstall t2-cli and try setting up the ambient module afterwards because even if standard JavaScript code runs ok, when I try running the example code for the ambient module, I get the following

@johnnyman727 any thoughts?

@rwaldron
Copy link
Contributor

rwaldron commented Aug 2, 2016

@vzamfirescu thanks for your patience, I will make sure @johnnyman727 takes a look at this later today after our meeting

@vzamfirescu
Copy link
Author

@rwaldron @johnnyman727 Thanks a lot for the help, I really appreciate it! :)

@vzamfirescu
Copy link
Author

vzamfirescu commented Aug 3, 2016

@rwaldron @johnnyman727

After multiple restarts, npm cache cleans and t2-cli reinstalls, the ambient module started working out of a sudden.

Instead of the previous error, I got the following error for the first couple of example code runs:

D:\<MY_TESSEL>\ambient>t2 run ambient.js
INFO Looking for your Tessel...
INFO Connected to <MY_TESSEL>.
INFO Building project.
INFO Writing project to RAM on <MY_TESSEL> (41.472 kB)...
INFO Deployed.
INFO Running ambient.js...
Code loaded on Tessel
Could not retrieve firmware version and module ID. Attempting update.
Uploading new firmware...
Update finished!
[Error: Unable to communicate with module. Are you sure it's plugged in?]

After getting the above error a couple of times, the module started working out of the blue, without any additional action from my side:

D:\<MY_TESSEL>\ambient>t2 run ambient.js
INFO Looking for your Tessel...
INFO Connected to <MY_TESSEL>.
INFO Building project.
INFO Writing project to RAM on <MY_TESSEL> (41.472 kB)...
INFO Deployed.
INFO Running ambient.js...
Code loaded on Tessel
Could not retrieve firmware version and module ID. Attempting update.
Uploading new firmware...
Update finished!
Light level: 0.01367188   Sound Level: 0.01953125
Light level: 0.01269531   Sound Level: 0.01953125
...

However, I still find it strange that each time I run my code, the following steps always get executed:

Could not retrieve firmware version and module ID. Attempting update.
Uploading new firmware...

@johnnyman727
Copy link
Contributor

@vzamfirescu it looks like you're hitting a known issue: tessel/ambient-attx4#69

Closing this particular issue but feel free to follow-up on the one I linked above.

The Ambient Module has been having some issues lately but nobody (including myself) has had time to look into it. I'm happy to help advise for anyone that wants to investigate on their own.

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

No branches or pull requests

4 participants