Comments (11)
@craigwblake I don't have enough to go on here. How did you install this? which json
Can you show me the content of the json script file that is running?
from json.
Sure, I'll share what I can. I run "apt-get install node" to install node then ran "npm install -g jsontool" per the instructions on the main page. That all completed without error, and it installed the json command in "/usr/local/bin/json"
Here is the content of the file in that location:
#!/usr/bin/env node
//
// json -- a 'json' command for massaging JSON on the command line
//
// See <https://github.com/trentm/json>.
//
var VERSION = "6.0.0";
var p = console.warn;
var util = require('util');
var assert = require('assert');
... most of file ellided because have enough here to confirm this is *my* json tool :) ...
};
}
main(process.argv);
}
from json.
@craigwblake Thanks. Okay, what is the output of:
which node
`which node` --version
`which node` /usr/local/bin/json --version
I've not seen that behaviour (calling json --version
exiting showing nothing). I've also never used the apt-provided node on Ubuntu.
from json.
Well I ran that and it didn't work I looked into and found out that on Ubuntu the Node.js binary is installed as 'nodejs'.
That certainly explains why it wasn't working, but it's definitely not obvious from the lack of output. Maybe it's worth checking for 'nodejs' as the executable if 'node' fails in your script?
from json.
Also, for reference there is a different 'node' binary on Ubuntu (which is why nodejs could not use the name) which when run outputs nothing. Quite an annoying coincidence that made the problem non-obvious.
from json.
What?! That's crazy. I don't know a reasonable way to deal with that on json
's end. There must be many node.js-based command line tools that have this same issue.
A little bit of searching turned this up: http://askubuntu.com/questions/235655/node-js-conflicts-sbin-node-vs-usr-bin-node Specifically:
sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs
sudo apt-get install nodejs
# Confirm it worked
node --version # v0.10.13
ls -la `which node` # ... /usr/bin/node -> /etc/alternatives/node
Is that a reasonable workaround for you? I'm not familiar with current and past Ubuntu node.js packaging naming.
from json.
I tried but it still didn't link the 'nodejs' binary to 'node'. Oh well, I manually linked it so it works now. Perhaps it would be sufficient for a warning for Ubuntu users on your installation instructions?
from json.
@craigwblake I got a response from @isaacs:
The answer is that this is a known bug in debian-stable. He should either: a) install from source, b) install from the binary tarballs on http://nodejs.org/ or c) use chrislea's PPA https://launchpad.net/~chris-lea/+archive/node.js/
it is my understanding that Debian is changing this moving forward.
so future versions will have the "nodejs" package install a binary called "node", and have it conflict with the "ham-node" package
from json.
README.md warning added in the install section. Thanks!
from json.
Instead of #!/usr/bin/env node
, try this
#!/usr/bin/env sh
':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@"
Say whaaaat?
It's a polyglot script. sh
sees it as a shell script that tries to exec
itself using either nodejs
or node
; node
sees it as a no-op and executes everything below. Everyone is happy!
Credit goes to guys on stackexchange.
from json.
See #74.
The warnings in docs and install scripts are probably no longer required with this hack and could be removed.
from json.
Related Issues (20)
- Possibility to skip validation? or to support json5 (that supports comments in json) HOT 1
- How to reverse `--items` back to object form? (filter sub-objects)
- colon and semicolon are not allowed as keys HOT 2
- pretty printing does not support tabs
- fix bug json HOT 1
- doesn't work in powershell
- Failing to parse a GeoJSON that is valid elsewhere?
- Cannot set a value for a key with a period HOT 1
- Command Injection HOT 2
- List indexing not working HOT 1
- Potential Code Injection Vulnerability in -d Argument HOT 3
- Can I remove properties in a json file? HOT 2
- How to print sub-items of a key? HOT 3
- command line if value has a space lookups cannot be specified with in-place editing
- How to process key with colon and other characters? HOT 3
- json parse get wrong anwser HOT 1
- Who to contact for security issues
- having problems on trying to change this.obj['name.ext'].value
- How can I replace the value if the key name is with a dot? HOT 2
- update docs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json.