ternjs / tern_for_vim

Tern plugin for Vim
MIT License
1.83k stars 100 forks source link

Getting "JSON parse error: Unexpected token &" #44

Closed shawndumas closed 11 years ago

shawndumas commented 11 years ago

capture

I have installed it on my Mac (OSX Mavericks), and on my Linode (Ubuntu 12.04.3 LTS) and it's working wonderfully but I cannot seem to get it working on my Red Hat Enterprise Linux Server release 6.4 (Santiago).

The repo that works in two out of the three envs is my fork of emile.

Using Vundle to load. I ran npm install in .vim/bundle/tern_for_vim/.

My .vimrc just in case you need it.

marijnh commented 11 years ago

Could it be that your .tern-project (or a .json definition file) isn't syntactically valid?

shawndumas commented 11 years ago

Thanks for your input. I think my .tern-project file is ok. I intentionally added a syntax error to it and the tern server failed to start, but that's not what's happening with my original file. Also, this same project is working on my two other computers without issue.

I relized that my .gitignore was ignoring the file so I changed it and added my .tern-project file to the repo.

Thanks again.

marijnh commented 11 years ago

So that didn't solve it? Try running the server (bin/tern manually from the directory that has your .tern-project file, and see if it spits out something useful when/if it crashes.

shawndumas commented 11 years ago

Like this?

capture

If so I see no discernible errors...

marijnh commented 11 years ago

Well, that's too bad. Does Vim's message window show any more details when the problem happens?

shawndumas commented 11 years ago

No. Just the JSON parse error: Unexpected token & error.

shawndumas commented 11 years ago

Would vim --version text help?

Here is the one that's not working.

Here is the one that is working.

Here are just the diffs.

Here are all the settings compared.

shawndumas commented 11 years ago

I added the following to tern:

capture

And this was the result:

capture

marijnh commented 11 years ago

Thanks for looking into this further. So it appears the client (the Vim plugin) is sending a request containing just '&&&'. That is truly bizarre. I looked over the code again, but it should definitely be sending the output of JSON.dumps, which can't ever sanely be '&&&'.

Do you have a network sniffer installed? (Something like wireshark or ngrep.) It would be interesting to see the actual traffic that's being generated. Or maybe add log statements to the plugin code to see what it is trying to do.

shawndumas commented 11 years ago

I don't know vimscript and I don't have ngrep or wireshark installed (and I'd have to build from source on that box) so I just socat'ed up a proxy, changed the port in .tern-port to point to it and dumped the req/resp (socat -v TCP-LISTEN:xxxx TCP:localhost:xxxx).

It's messy but here is what is getting sent.

[edit] compiled and installed ngrep; here's the output.

shawndumas commented 11 years ago

sorry, hit the close button on my iPhone by accident.

marijnh commented 11 years ago

Thanks for capturing the net traffic. It does look like the client is sending perfectly valid JSON, yet the server ends up getting a request containing just a bunch of ampersands. This is a little odd.

Since the problem appears to depend on the vim/python side, an HTTP client library error seems likely. But the request you captured looks valid. The setting comparison also doesn't point out any obvious problems. Python 2.6 vs Python 2.7 seems a likely candidate, but we've tested with 2.6 before, and that time it worked.

I'm stumped, I must say.

shawndumas commented 11 years ago

ok, thanks for trying.