-
Notifications
You must be signed in to change notification settings - Fork 65
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
cordova plugin add: "Unexpected end of JSON input" #423
Comments
Sorry, to say the changed lined "works" wasn't correct. This output comes back:
There is an extra "error" block at the end of the output. Very odd. |
Indeed, very odd. Does the raw command work for you? Try running: If it reproduces directly while running |
Hello there Norman, running the command in a regular shell prompt works
fine. Is it something to do with the snap version of npm/node, I wonder?
I'll try to repro with a non-snap version tomorrow.
Anything else you'd like me to try, of course, just let me know.
ในวันที่ ศ. 7 ก.ค. 2023 19:57 Norman Breau ***@***.***>
เขียนว่า:
… There is an extra "error" block at the end of the output. Very odd.
Indeed, very odd.
Does the raw command work for you? Try running: npm view
***@***.*** --json
If it reproduces directly while running npm, then that tells us that NPM
is trying to do something that it doesn't have permission to do. If the
error is inside the output of execa... then I would think it's NPM that is
hitting that error...
—
Reply to this email directly, view it on GitHub
<#423 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG5TKBQ7MQUCDNU3XEE5UTXPABS3ANCNFSM6AAAAAA2ANFELE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I do know that running apps under snap uses AppArmour which gives processes a fine grain control over what they can or can't do, or what directories/files they can access or can't access. I personally don't use snap cause often times these settings appears to be misconfigured for proper usage... at least that was my experience with them. But if you're running a snap version, and that's the version running in the same regular prompt, then I would have expected the issue to reproduce if it was an apparmour sandbox issue. I use If all else fails... I think we'll need to run the command line under the node debugger, or add print statements to try to figure out where that error is coming from exactly. |
Thanks breautek, this is working fine for me with both local and global installs of Cordova when I use node installed via nvm. I strongly suspect it's something weird with the snap version, and I might refer this issue to the snap maintainers. The error message is kind of a red herring, I think, in that valid output is also returned and |
Yah it is strange. Even the app armor thing I mentioned before, it's still strange to see the correct stdout from NPM followed by an error in stdout. It looks like it's been confirmed to be an issue with the snap version of Node. Because it isn't a bug actionable by Cordova I'll be closing this issue. |
Bug Report
Problem
What is expected to happen?
Plugins can be added using the "cordova plugin add" command
What does actually happen?
A single line of output is displayed: "Unexpected end of JSON input"
Information
I've tracked this issue to
cordova-lib/src/cordova/plugin/util.js
, in the "info" function. The call toexeca("npm", ...
) is returning no output. However, this doesn't seem to be an issue with "execa" because other calls such as "ls" are returning output fine.If you change that line to the following:
Then it works. So I suspect it's something weird with npm or node's behaviour, not flushing to stdout or something like that.
Command or Code
npx cordova plugin add cordova-plugin-device
Environment, Platform, Device
Ubuntu 22.04.2
Version information
"node" Snap 18.16.1 (Rev 7588)
Node 18.16.1
NPM 9.5.1
Cordova 12.0.0
Checklist
The text was updated successfully, but these errors were encountered: