lukehoban / atom-ide-flow

Atom IDE support for Flow
MIT License
87 stars 17 forks source link

Does not seems to work with flow version 0.17.0 #41

Open Gozala opened 8 years ago

Gozala commented 8 years ago

running type check produces following error in the web-inspector console:

env: node: No such file or directory util-flow-command.coffee:30
Gozala commented 8 years ago

I've briefly looked into and it seems like error is coming from flow itself, more specifically here is some of my observations:

I set a breakpoint on the above mentioned line to try to figure what is going on and found out following:

screen shot 2015-10-12 at 11 10 22 am

So I tried running same from the terminal:

/usr/local/bin/flow type-at-pos 22 48 --json --path /Users/gozala/Projects/reflex-virtual-dom-renderer/src/node.js

That keeps hanging while this produces similar error as I see in terminal:

/usr/local/bin/flow type-at-pos 22 48 /Users/gozala/Projects/reflex-virtual-dom-renderer/src/node.js --json
File not found

While following seems to work fine:

/usr/local/bin/flow type-at-pos /Users/gozala/Projects/reflex-virtual-dom-renderer/src/node.js 22 48 --json
{"type":"(unknown)","reasons":[],"path":"","line":0,"endline":0,"start":1,"end":0}

My guess is something else deals with --path and it also is passed after line & colon which makes my guess is no longer supported by flow@0.17.0

Gozala commented 8 years ago

Ok so I have tried changing following line https://github.com/lukehoban/atom-ide-flow/blob/master/lib/util-flow-command.coffee#L79 to:

      args: ['type-at-pos', fileName, bufferPt.row + 1, bufferPt.column + 1, '--json']

Which does not seem to resolve it. From web inspector I can now get a command to run in my terminal:

getFlowCommand() + ' ' + args.join(' ') // => /usr/local/bin/flow type-at-pos /Users/gozala/Projects/reflex-virtual-dom-renderer/src/node.js 14 36 --json

and running it in terminal produces following:

/usr/local/bin/flow type-at-pos /Users/gozala/Projects/reflex-virtual-dom-renderer/src/node.js 14 36 --json
{"type":"(unknown)","reasons":[],"path":"","line":0,"endline":0,"start":1,"end":0}
Gozala commented 8 years ago

So I'm clueless to what is going on, only other thing worth noting is that I have flow installed through flow-bin package which creates /usr/local/bin/flow symlink:

readlink /usr/local/bin/flow
../lib/node_modules/flow-bin/cli.js

But updating flow path to an actual file still does not seem to work so I'm giving up.

Gozala commented 8 years ago

After digging further into it I realized that flow-bin is node-wrapper that uses actual flow binary bundled with it under vendor/flow. I have updated my flow path to /usr/local/lib/node_modules/flow-bin/vendor/flow which resolved the issue.

Give that flow-bin is one of the recommended install paths on the flow readme I suggest to either handle such installation or at least add section into readme to document this as a pitfall.

Gozala commented 8 years ago

BTW changes I made originally did not turn out to be necessary after fixing the path.

anthillape commented 8 years ago

For people who stumble across this issue I had a similar initial error env: node: No such file or directory util-flow-command.coffee:41 This turned out to be because my path (in atoms debugger, using process.env.PATH) did not include /usr/local/bin which is where npm installed flow-bin. I was able to use flow in my terminal because the correct PATH is set in my .zshrc. It turned out that this issue would only occur when I opened atom from the dock, and not when I opened it from the command line. There is a solution to that specific issue here.

madson commented 7 years ago

Running this command worked for me $ npm install --global flow-bin.