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

Invalid Result received from JSHint #145

Closed
dtheb opened this issue Jul 19, 2015 · 62 comments
Closed

Invalid Result received from JSHint #145

dtheb opened this issue Jul 19, 2015 · 62 comments
Labels

Comments

@dtheb
Copy link

dtheb commented Jul 19, 2015

Ive been told by steelbrain/linter#762 to post it here

am getting the exact error on that issue but looks like it was patched at linter but somehow its still there for me

error is a notification:

Invalid Result received from JSHint
Check your console for more info. It's a known bug on OSX. See https://github.com/AtomLinter/Linter/issues/726

console only got JSHint Result:

@steelbrain
Copy link
Contributor

Can you please post the jshint config you're using? Are you using the bundled jshint or specifying the path explicitly?

@dtheb
Copy link
Author

dtheb commented Jul 19, 2015

not using a config its on the default .. i checked the default path to jshint in the settings page it seems right and jshint is there everything seems fine

and now that you asked i opened my config there is only

  "linter-jshint": {}

so.. it diidn't write to the config or this is normal ?

@steelbrain
Copy link
Contributor

It is normal, so can you do this and confirm if it works for you?

rm ~/.atom/packages/linter-jshint
apm install linter-jshint

@dtheb
Copy link
Author

dtheb commented Jul 19, 2015

nope same issue

@steelbrain
Copy link
Contributor

Okay, so can you post the output of

cat ~/.atom/packages/linter-jshint/node_modules/atom-linter/package.json

@dtheb
Copy link
Author

dtheb commented Jul 20, 2015

{
  "name": "atom-linter",
  "version": "2.0.1",
  "description": "base atom linter classes",
  "main": "lib/helpers",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+ssh://git@github.com/AtomLinter/atom-linter.git"
  },
  "keywords": [
    "atom",
    "linter"
  ],
  "author": {
    "name": "Dmitry Tsoy"
  },
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/AtomLinter/atom-linter/issues"
  },
  "homepage": "https://github.com/AtomLinter/atom-linter#readme",
  "dependencies": {
    "xregexp": "latest"
  },
  "gitHead": "7aefdf7554abbb4c9983730293a4f11726b944f4",
  "_id": "atom-linter@2.0.1",
  "_shasum": "dbe3fa35dcfd40752e62a6b07521a265f1829d8e",
  "_from": "atom-linter@>=2.0.0 <3.0.0",
  "_npmVersion": "2.12.1",
  "_nodeVersion": "2.3.4",
  "_npmUser": {
    "name": "steelbrain",
    "email": "foo@gmail.com"
  },
  "dist": {
    "shasum": "dbe3fa35dcfd40752e62a6b07521a265f1829d8e",
    "tarball": "http://registry.npmjs.org/atom-linter/-/atom-linter-2.0.1.tgz"
  },
  "maintainers": [
    {
      "name": "hd-deman",
      "email": "hd.deman@gmail.com"
    },
    {
      "name": "steelbrain",
      "email": "foo@gmail.com"
    },
    {
      "name": "asaayers",
      "email": "Asa@AsaAyers.com"
    }
  ],
  "directories": {},
  "_resolved": "https://registry.npmjs.org/atom-linter/-/atom-linter-2.0.1.tgz",
  "readme": "ERROR: No README data found!"
}

@steelbrain
Copy link
Contributor

Now I am super-confused, it looks fine! why doesn't it work 😃

@dtheb
Copy link
Author

dtheb commented Jul 20, 2015

no idea.. can i create some dump file or something for you ??

@steelbrain
Copy link
Contributor

Sure. Anything that helps me reproduce this behaviour

@dtheb
Copy link
Author

dtheb commented Jul 20, 2015

is there anything specific i need to run for linter-jshint error/dump/debug file ??

@steelbrain
Copy link
Contributor

What's your atom version again?

@dtheb
Copy link
Author

dtheb commented Jul 20, 2015

1.0.2 latest version

@steelbrain
Copy link
Contributor

@AtomLinter/linter @AtomLinter/owners any ideas?

@elebetsamer
Copy link

elebetsamer commented Jul 20, 2015

I'm also having this issue on Windows 8.1 now as well, but didn't have the problem with version 1.1.1. I don't have a .jshint config file either, so it is just running as default. I already tried removing and reinstalling the package as well.

Atom: 1.0.2
linter: 1.2.4
linter-jshint: 1.1.2

$ cat ~/.atom/packages/linter-jshint/node_modules/atom-linter/package.json

{
  "name": "atom-linter",
  "version": "2.0.1",
  "description": "base atom linter classes",
  "main": "lib/helpers",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+ssh://git@github.com/AtomLinter/atom-linter.git"
  },
  "keywords": [
    "atom",
    "linter"
  ],
  "author": {
    "name": "Dmitry Tsoy"
  },
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/AtomLinter/atom-linter/issues"
  },
  "homepage": "https://github.com/AtomLinter/atom-linter#readme",
  "dependencies": {
    "xregexp": "latest"
  },
  "gitHead": "7aefdf7554abbb4c9983730293a4f11726b944f4",
  "_id": "atom-linter@2.0.1",
  "_shasum": "dbe3fa35dcfd40752e62a6b07521a265f1829d8e",
  "_from": "atom-linter@>=2.0.0 <3.0.0",
  "_npmVersion": "2.12.1",
  "_nodeVersion": "2.3.4",
  "_npmUser": {
    "name": "steelbrain",
    "email": "foo@gmail.com"
  },
  "dist": {
    "shasum": "dbe3fa35dcfd40752e62a6b07521a265f1829d8e",
    "tarball": "http://registry.npmjs.org/atom-linter/-/atom-linter-2.0.1.tgz"
  },
  "maintainers": [
    {
      "name": "hd-deman",
      "email": "hd.deman@gmail.com"
    },
    {
      "name": "steelbrain",
      "email": "foo@gmail.com"
    },
    {
      "name": "asaayers",
      "email": "Asa@AsaAyers.com"
    }
  ],
  "directories": {},
  "_resolved": "https://registry.npmjs.org/atom-linter/-/atom-linter-2.0.1.tgz",
  "readme": "ERROR: No README data found!"
}

@steelbrain steelbrain changed the title Invalid Result received from JSHint atom-community/linter#762 Invalid Result received from JSHint Jul 20, 2015
@Dilatorily
Copy link

On Linux, I upgraded from linter-jshint from 1.1.1 to 1.1.2 today and I received the same issue.

By downgrading atom-linter to 2.0.0, the issue went away.

@steelbrain
Copy link
Contributor

@Dilatorily that doesn't really make any sense, as the patch release only contains one commit steelbrain/atom-linter#11

@Dilatorily
Copy link

@steelbrain I would guess there are unwanted attributes in the process.env.

It still seems to be working if I only copy the PATH environment variable.

_exec: (command, args = [], options = {}, isNodeExecutable = false) ->
    options.stream ?= 'stdout'
    options.env ?= {}
    options.env.PATH = process.env.PATH
    return new Promise (resolve, reject) ->
      if isNodeExecutable
        options.env ?= {}
        options.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE = '1' # Needed for electron
      spawnedProcess = child_process.spawn(command, args, options)
      data = []
      if options.stream is 'stdout'
        spawnedProcess.stdout.on 'data', (d) -> data.push(d.toString())
      else if options.stream is 'stderr'
        spawnedProcess.stderr.on 'data', (d) -> data.push(d.toString())
      if options.stdin
        spawnedProcess.stdin.write(options.stdin.toString())
        spawnedProcess.stdin.end() # We have to end it or the programs will keep waiting forever
      spawnedProcess.on 'error', (err) ->
        reject(err)
      spawnedProcess.on 'close', ->
        resolve(data.join(''))

@steelbrain
Copy link
Contributor

@Dilatorily we actually have to copy a few HOME envs to make the config file finding work.

@Dilatorily
Copy link

Which ones do we need exactly?

@steelbrain
Copy link
Contributor

@Dilatorily
Copy link

The only variable that is set is HOME and adding it to the environment creates the error.

@pboudoin
Copy link

I've got this problem too :(

@ChiggerChug
Copy link

Also having this issue on Windows in Atom it seems to be occurring on line 75 of main.coffee right after the JSON.parse(output)

@vnabet
Copy link

vnabet commented Jul 20, 2015

Same issue this morning with last 1.1.2 update

@steelbrain
Copy link
Contributor

Can anyone confirm that downgrading linter-jshint's atom-linter npm module to 2.0.0 works?

@ChiggerChug
Copy link

My technical know-how is not great on this, I'll give it a shot if you can tell me where to look?

@steelbrain
Copy link
Contributor

cd ~/.atom/packages/linter-jshint
npm install atom-linter@2.0.0

@ChiggerChug
Copy link

Yup that fixed the problem! Cheers for the help man. Any idea what's causing the issue?

@steelbrain
Copy link
Contributor

Ummm, can you change the executable path to

require('path').join(__dirname, '..', '.bin', 'jshint')

@spacejack
Copy link

I have the same problem on Windows 7 & 8.1 machines. jshint is unusable for me. :(

@mjomble
Copy link

mjomble commented Jul 20, 2015

Still the same problem. It uses the correct path to an existing .bin\jshint file, but this file is directly executable only in Unix. On Windows it needs to be executed as an argument to the node executable.

@steelbrain
Copy link
Contributor

Aaahh! I'll try something myself as soon as I'm on windows

@dtheb
Copy link
Author

dtheb commented Jul 20, 2015

i played around a bit with your path this fixed it

return helpers.exec(path.join(__dirname, '..', 'node_modules/.bin', 'jshint.cmd'), parameters, {stdin: text}).then (output) ->

had to add node_module for .bin and .cmd for jshint

@steelbrain
Copy link
Contributor

@ahmed-90 does it work with this path? 'cause if it does then it's a very likely electron problem.

@mjomble
Copy link

mjomble commented Jul 20, 2015

Works for me with the jshint.cmd path.
Also, I changed 'node_modules/.bin' to 'node_modules', '.bin' in that line.

@dtheb
Copy link
Author

dtheb commented Jul 20, 2015

yes it worked for me it was looking for jshint at linter-jshint/.bin but jshint is in linter-jshint\node_modules\.bin
also its windows so it needs the jshint.cmd not the native jshint

@sethkinast
Copy link

One more confirmation that downgrading to 2.0.0 works, OS X 10.10. I use nvm and don't have a global Node installed.

@steelbrain
Copy link
Contributor

steelbrain/atom-linter#13 is gonna fix this people

@steelbrain
Copy link
Contributor

So people, we are unable to reproduce this behaviour, we are gonna need someone who is affected by this bug to contact us in #linter of atom slack and/or maybe share screens to help debug this.

@joefitzgerald
Copy link

It would help if people could report, when experiencing this issue:

  • Did you launch from the terminal / command line, or via some other mechanism?
  • Do you have a copy of jshint on your path? (which jshint)
    • What happens if you remove it from your path, temporarily?
    • What happens if you add it to your path, temporarily?

@Dilatorily
Copy link

  • I get the same error either I'm running Atom from a shortcut or from the command line.
  • I don't have jshint installed globally. So doing a which jshintreturns me nothing.
    • If I install a global jshint (npm install -g jshint), I get the same error.

Also, as I said in an earlier comment, the moment I pass the HOME variable to jshint, the issue is reproduced for me.

Here is the dump of my process.env.

ATOM_HOME: "/home/dang/.atom"
ATOM_SHELL_INTERNAL_RUN_AS_NODE: "1"
CHROME_DESKTOP: "Atom.desktop"
CLUTTER_IM_MODULE: "xim"
DBUS_SESSION_BUS_ADDRESS: "unix:abstract=/tmp/dbus-nyvF2sAylO,guid=cb7784eb91c79f0b15af69da55adbf78"
DEFAULTS_PATH: "/usr/share/gconf/gnome.default.path"
DESKTOP_SESSION: "gnome"
DISPLAY: ":0"
GDMSESSION: "gnome"
GIO_LAUNCHED_DESKTOP_FILE: "/usr/share/applications/atom.desktop"
GIO_LAUNCHED_DESKTOP_FILE_PID: "3310"
GJS_DEBUG_OUTPUT: "stderr"
GJS_DEBUG_TOPICS: "JS ERROR;JS LOG"
GNOME_DESKTOP_SESSION_ID: "this-is-deprecated"
GPG_AGENT_INFO: "/run/user/1000/keyring/gpg:0:1"
GTK_IM_MODULE: "xim"
HOME: "/home/dang"
LANG: "en_CA.UTF-8"
LANGUAGE: "en_CA:en"
LOGNAME: "dang"
MANDATORY_PATH: "/usr/share/gconf/gnome.mandatory.path"
NODE_ENV: "production"
NODE_PATH: "/usr/share/atom/resources/app.asar/exports"
PATH: "/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
PWD: "/home/dang"
QT4_IM_MODULE: "xim"
QT_IM_MODULE: "ibus"
SESSION_MANAGER: "local/ubuntu:@/tmp/.ICE-unix/1623,unix/ubuntu:/tmp/.ICE-unix/1623"
SHELL: "/bin/bash"
SHLVL: "0"
SSH_AGENT_PID: "1699"
SSH_AUTH_SOCK: "/run/user/1000/keyring/ssh"
USER: "dang"
USERNAME: "dang"
WINDOWPATH: "7"
XAUTHORITY: "/var/run/gdm/auth-for-dang-PXLPoq/database"
XDG_CONFIG_DIRS: "/etc/xdg/xdg-gnome:/etc/xdg"
XDG_CURRENT_DESKTOP: "GNOME"
XDG_DATA_DIRS: "/usr/share/gnome:/usr/local/share/:/usr/share/"
XDG_MENU_PREFIX: "gnome-"
XDG_RUNTIME_DIR: "/run/user/1000"
XDG_SEAT: "seat0"
XDG_SESSION_DESKTOP: "gnome"
XDG_SESSION_ID: "c2"
XDG_VTNR: "7"
XMODIFIERS: "@im=ibus"

@filipesilva
Copy link

@Dilatorily you posted your Google api key there. You should change it, because there are usually automated bots hunting github for private keys.

@Leftyx
Copy link

Leftyx commented Jul 21, 2015

Just upgraded to ver 1.1.2 and got the same issue.
Windows 7 64bit.

@BlaM
Copy link

BlaM commented Jul 21, 2015

For anybody in need of a quick fix until the problem is actually solved: This is a combination that works for me:

apm remove linter linter-jshint
apm install linter@1.2.3 linter-jshint@1.0.5

@Leftyx
Copy link

Leftyx commented Jul 21, 2015

@BlaM: Thanks. It works.

@dtheb
Copy link
Author

dtheb commented Jul 21, 2015

@steelbrain am in the slack channel pm me when you want to test :)

@dtheb
Copy link
Author

dtheb commented Jul 21, 2015

@steelbrain here is the code you requested:

  _exec: (command, args = [], options = {}, isNodeExecutable = false) ->
    options.stream ?= 'stdout'
    options.env ?=
        Path: process.env.Path
        PATH : process.env.PATH
        HOMEDRIVE: process.env.HOMEDRIVE
        HOMEPATH: process.env.HOMEPATH
        HOME: process.env.HOME
        USER: process.env.USER
        USERNAME: process.env.USERNAME

@steelbrain
Copy link
Contributor

To all the other participants, I went on teamviewer with @ahmed-90 and narrowed the bug down to the line where we are doing

options.env ?= process.env

Removing that line fixes the issue, but it disallows jshint to search for .jshintrc. We'll be posting a solution soon.

@sethkinast
Copy link

As an extra data point to confirm that, I downgraded to 2.0.0 and linting works, but the linter doesn't pick up my .jshintrc. So I think you're on to it.

@Dilatorily
Copy link

@filipesilva Thanks for the heads up! It seems my VM copied the environment variables.

@hellerbarde
Copy link

EDIT: I am on Windows 7 Professional.

I have the same bug, I'll post my analysis here. I think it's related to this issue: electron/electron#1463. Because when I change the code that calls jshint at main.coffee:52 to this:

parameters = [@executablePath, '--reporter', reporter, '--filename', filePath]
        if textEditor.getGrammar().scopeName.indexOf('text.html') isnt -1 and 'source.js.embedded.html' in @scopes
          parameters.push('--extract', 'always')
        parameters.push('-')
        return helpers.exec("node", parameters, {stdin: text}).then (output) ->

it works again. It seems that electron is somehow not picking up on the

options.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE = '1' # Needed for electron

set in helpers.coffee:26

EDIT/UPDATE:

I should have elaborated a bit:
The Issue I have observed is that the atom.exe binary (it's an "electron" binary, to be precise) that is used to execute the node.js code from jshint does not do that. If you don't tell the binary that it has to act as node.js, it will just run the Atom editor, as it usually should. The variable ATOM_SHELL_INTERNAL_RUN_AS_NODE is used to switch this behaviour.

But now it seems that it either ignores the variable or windows screws around with the environment.

And by the way, the whole error comes from the binary returning immediately, (because it forks right away) leading to the STDOUT being empty. That is then fed into JSON.parse(). Which is not happy about parsing an empty string (which is confusing in its own right, to be honest.)

@steelbrain
Copy link
Contributor

@hellerbarde did you try replacing options.env ?= process.env by what @ahmed-90 wrote?

@steelbrain
Copy link
Contributor

People, I've pushed a patch release, it contains latest version of atom-linter that is now using Atom's Buffered and Node Buffered Processes for spawning part. I hope it'll fix it for you

@hellerbarde
Copy link

For the record: @steelbrain I did all the research before finding this issue. I only found an old issue at first. So no, I didn't try that yet. I will try your update now.

UPDATE: Yep, that fixed it for me. 👍

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

No branches or pull requests