linter-flow icon indicating copy to clipboard operation
linter-flow copied to clipboard

Should support use project local flow bin

Open kerryChen95 opened this issue 7 years ago • 10 comments

I use linter-flow without npm i -g flow-bin, and get error:

~/.atom/packages/linter/lib/linter-registry.js:159 [Linter] Error running Flow Error: Failed to spawn command flow. Make sure flow is installed and on your PATH

I think linter-flow should support use project local flow bin as optional, for example use <project root>/node_modules/.bin/flow if it exists, so we can use the same version of flow bin for both Atom's linter-flow and command npm run flow.

kerryChen95 avatar Jun 05 '17 04:06 kerryChen95

Any updates on this?

nwshane avatar Jul 18 '17 20:07 nwshane

This is also reflected in the Flow install docs as a best practice: https://flow.org/en/docs/install/

Flow works best when installed per-project with explicit versioning rather than globally.

stackptr avatar Jul 18 '17 22:07 stackptr

I thought using local flow didn't work when I was looking into this yesterday, but it turns out that I had my linter package disabled. I'm using linter-flow 5.6.0, I set ./node_modules/.bin/flow as my flow executable in linter-flow's settings, and it's working as expected.

Hope that's useful to someone.

nwshane avatar Jul 19 '17 16:07 nwshane

It makes sense that that setting would work, but I don't feel it's very intuitive + the default assumption is a global install when that seems like it should be the special case (with the default to using node_modules)

I was looking at how AtomLinter/linter-eslint accomplishes using local vs global versions of the linting tool (though it seems I might be unaware of certain requirements specifically relating to flow running as a server) and it seems like some of that logic can be ported pretty readily. I would be a fan of a simpler solution to default to ./node_modules/.bin/flow unless a global instance is indicated, but I think this falls short when working directories are set inside/outside that root directory where node_modules lives.

Hoping to submit a PR for this issue soon!

stackptr avatar Jul 19 '17 21:07 stackptr

For anyone else on Windows, you'll need to use backslashes instead of forward slashes (.\node_modules\.bin\flow)

alexbainter avatar Aug 01 '17 21:08 alexbainter

I can't get the ./node_modules/.bin/flow trick to work and would really prefer either than flow was bundled in the plugin or that the plugin was able to find and use a local flow binary rather than installing one globally.

far-blue avatar Aug 21 '17 12:08 far-blue

+1 for project specific "local". This is how linter-eslint works and so that should this very one also followed same pattern

mifrej avatar Aug 28 '17 15:08 mifrej

This is a rough first pass: https://github.com/AtomLinter/linter-flow/pull/180

stackptr avatar Sep 06 '17 00:09 stackptr

I think I'm getting the same issue, but I have the linter package enabled.

[Linter] Error running Flow Error: Failed to spawn command flow. Make sure flow is installed and on your PATH

Or is this a different issue?

screen shot 2018-06-15 at 3 01 33 pm

mileung avatar Jun 15 '18 22:06 mileung

This in particular makes it even less obvious image

el1f avatar Mar 03 '19 22:03 el1f